-
Missiles Within Movieclips
I have a Helicopter MC that i want to shoot a missile when a button is pressed but when it shoots and the helicopter moves the missile moves with the helicopter still, is there anyway that i can fix this, i've tried putting the missiles on a different layer but then they don't move with the helicopter.
PLEASE HELP!!!
thanks
Blair3113
-
Hi Blair. You really should treat the missiles as different MovieClips (or Sprites, if you're working with ActionScript 3). I'll assume you're using AS2.
Have you tried attaching a new missile MovieClip each time the 'fire' button is pressed, and keeping track of the layer (or depth) the previous bullet was placed at? You could then name each missile MovieClip according to the depth it'll be getting placed at, as follows:
attachMovie("missile", "missile"+depthCounter, depthCounter);
depthCounter++;
After each time you add a missile, you increment the depthCounter. That way, you never get a missile on the same depth as another missile. Better still than just naming each missile according to its depth, you should store references to the missiles, as they are created, in an array. Then, you can run through that array, checking whether the missiles are still in the game bounds, etc. - let me know how it goes, though.
-
THANKS HEAPS, i am using AS2 by the way
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|