A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: flash game design

  1. #1
    Member
    Join Date
    Mar 2009
    Posts
    35

    flash game design

    hi everyone

    this is my first post so apologies if I'm asking questions that might already have been covered.

    I'm currently doing a flash module as part of a postgrad course and we have to design an interactive flash presentation. Mine will be on scotland with an interactive drag n drop quiz, a sub game amongst other thing.

    For my game I'd like objects(well, midges!) to be generated randomly with a timer counting down and a scaore counting up to time how many objects were hit in the tim allowed.

    My problem is being so new to flash I'm not sure if this is too complicated to be aiming for. How would I generate objects randomly and register each time one is "hit" either by the cursor or a hand icon as the cursor?

    sorry its a bit long winded. any pointers would be appreciated.

    Thanks

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    It's not too complicated to aim for. You'll have to refine what you mean by "generated randomly" though. Do you mean appear at random times, random places? Random appearance?

    You'll want to create a Midge class to define what a Midge is. This class should take care of the event handling, like hitTesting and updating the score.

    Assuming you mean random times and places, you can do it something like this:
    Code:
    var allMidges:Array = new Array();
    var maxDelay:int = 2000; //maximum 2 seconds between midge appearances
    var midgeTimer:Timer = new Timer(Math.random()*maxDelay);
    midgeTimer.addEventListener(TimerEvent.TIMER, addMidge);
    
    function addMidge(e:TimerEvent):void{
      var m:Midge = new Midge();
      allMidges.push(m);
      midgeTimer.delay = Math.random()*maxDelay;
      m.x = Math.random() * maxwidth; //use whatever for max width.  add a minimum as well if you like
      m.y = Math.random() * maxheight; //use whatever for max height...
      addChild(m);
    }

  3. #3
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Edit: new forum software seems prone to doubleposts.
    Last edited by 5TonsOfFlax; 03-11-2009 at 02:21 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center