A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [F8] Shooting game bullet questions

  1. #1
    Member
    Join Date
    Sep 2006
    Posts
    82

    [F8] Shooting game bullet questions

    I am making a 2d eagle-eyed view shooting game that uses space to shoot. (The bullet is a long straight line)

    I have a few simple questions I hope someone could answer for me:

    1. How do I add a 'reload' effect so that someone playing the game can't just hold down space for a rapid fire?

    2. How do I make the bullet stop at one person in a situation like this:
    ----- --- but not having it go through the 1st guy.

  2. #2
    Member
    Join Date
    Sep 2006
    Posts
    82
    noone can help?

  3. #3
    Member
    Join Date
    Feb 2007
    Posts
    36
    1. how are you using the space are you saying onPress, or onKeyDown ?

    for number 2,

    just use a hitTest, if (yourBullet.hitTest Target){
    badGuy.removeMovieClip
    }
    something to that effect

  4. #4
    Member
    Join Date
    Sep 2006
    Posts
    82
    1. onkeydown
    2. that would remove the whole bullet

  5. #5
    Modulator Katnap Kaos's Avatar
    Join Date
    Nov 2003
    Location
    A shoebox outside of SM Megamall
    Posts
    149
    1. I usually make a blank MC and use it as a controller as something like this:

    Code:
    onClipEvent(enterFrame){
    	if(Key.isDown(Key.SPACE)){ //Or whatever key you're using
    		if(shotCount <= clipSize){
    			_root.attachMovie("mc.bullet", "bullet"+shotCount, shotCount+buffer);//Whatever you've
    			SHOOT SHOOT SHOOT SHOOT;//done to make it
    			SHOOT SHOOT SHOOT SHOOT;//shoot. It doesn't
    			SHOOT SHOOT SHOOT SHOOT;//have to look like this.
    			shotCount++;
    		} else {
    			reload == true
    		}
    	}
    }
    if(reload == true){
    	if(reloadComplete == reloadTIME){//Are we finished reloading?
    		shotCount=0;//reset
    		reload = false;//we finished reloading
    	} else {
    		reloadComplete ++;//still reloading
    	}
    }
    I find the problem with onKeyDown is that it sometimes goes funky chicken compared to the frame rate. With onClipEvent(enterFrame), the whole process is covered once per frame.

    2. Just remove the movieclip
    Last edited by Katnap Kaos; 02-19-2007 at 03:56 AM.
    As a Gamer, you play by the rules.
    As a Programmer, you play as God.

  6. #6
    Member
    Join Date
    Sep 2006
    Posts
    82
    oh ok thanks!

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