Be a Supporter!

Side Shooter Problem(as2)

  • 245 Views
  • 5 Replies
New Topic Respond to this Topic
Animattions
Animattions
  • Member since: Aug. 16, 2006
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Side Shooter Problem(as2) 2010-01-14 05:46:03 Reply

Hey guys, i'm currently stuck as what to do with my project.

It's basically a side scrolling shooter like Metal Slug, everything seems to work fine but one little thing. The problem is when i press Space bar it's meant to shoot a projectile, which id does...but...if i jump the bullet follows the y axis with me and if i face the other direction, it flips the bullet over to the other side of the screen.

Thank you, help would be very much appreciated

~Matt

scuddle666
scuddle666
  • Member since: Dec. 25, 2008
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to Side Shooter Problem(as2) 2010-01-14 06:06:17 Reply

When the space bar is pressed attach the bullet animation dynamically to the players current _x and _y and give the depth of the attached bullet animation something like 10+_root.numberofbullets
then you could fire multiple bullets at the same time without it fallowing you.
EX
_root.player.attachMovie("Bullets linkage ID","newname",10+_root.bulletsfired);
_root.bulletsfired+=1;
I'm sure theres other ways but thats just an easy one i thought of.
NOTE: if you do not have the depth change each time then each time the new bullet will replace the other, even if the previous is in mid flight.

henke37
henke37
  • Member since: Sep. 10, 2004
  • Offline.
Forum Stats
Member
Level 30
Blank Slate
Response to Side Shooter Problem(as2) 2010-01-14 06:52:53 Reply

Most likely you have no idea of what container you are adding the bullet to. Think over this carefully and you will figure out what you did wrong.


Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.

Animattions
Animattions
  • Member since: Aug. 16, 2006
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to Side Shooter Problem(as2) 2010-01-14 08:03:35 Reply

Thanks guys, i've changed it to a spawn area rather than a set area already and i have the code:-

_root.attachMovie("projectile", "projectile" + shots, _root.getNextHighestDepth());

but the problem is, is that it shoots continuously all connected together in a row, if i change the getNextHighestDepth to a unit number like:-

_root.attachMovie("projectile", "projectile" + shots, 1);

It shoots one at a time, but if you tap it doesn't finish off it's shot, it just disappears and re-appears out of the gun again. Any idea how to get it to shoot a reasonable amount at a time.

Thank you

~Matt

Animattions
Animattions
  • Member since: Aug. 16, 2006
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to Side Shooter Problem(as2) 2010-01-14 08:23:47 Reply

Here's a reference pic of what i mean, the top one is what i want, the bottom one is what i get

Side Shooter Problem(as2)

Benji
Benji
  • Member since: Aug. 14, 2008
  • Offline.
Forum Stats
Member
Level 15
Melancholy
Response to Side Shooter Problem(as2) 2010-01-14 08:47:24 Reply

look up something called "setInterval()"

Or, just use variables. E.G. when shoot is true, shoot, then set a timer for when shoot is true again.


BBS Signature