Jump to content


Photo

Need help with duplicate movie clip


  • Please log in to reply
2 replies to this topic

#1 Tudi

Tudi

    Young Padawan

  • Members
  • Pip
  • 42 posts

Posted 25 May 2005 - 11:07 AM

Hi ppl,

I'm trying to build a small, simplistic Flash game, and I'm stuck. The game is a space shooter and I designed the space ship and actionscripted it to move on pressing the direction keys, but....can't get it to shoot :lol:

The problem is that I want a laser or projectile to come from under the spaceship when the SPACE key is pressed. So I'm thinking I need a laser movie clip, which is to be duplicated whenever the space key is pressed. So here are my questions:

1. How do I give the duplicated movie clip coordinates according to the spaceship movie clip?

2. How do I make the duplicated movie clip to enable ONLY when I press the SPACE key (if (Key.isDown (KeySPACE) ?)

3. How do I make the movie clip come back to its initial coordinates once it passed the edges of the screen?



Hope you can help and thanks in advance :D.

Tudi

#2 MaRmAR

MaRmAR

    Young Padawan

  • Members
  • Pip
  • 18 posts
  • Location:Slovakia

Posted 29 May 2005 - 04:30 AM

1) This will duplicate a movieclip named "laserProjectileMovieclip" onto level 100 (set by variable 'newDepth') using new name "laserProjectileMovieclip1". X and Y coordinates are taken from spaceship's movieclip (spaceship._x & spaceship._y) so the projectile will appear exactly where the spaceship currently is.
var newDepth:Number=100;
laserProjectileMovieclip.duplicateMovieClip("laserProjectileMovieclip1", newDepth, {_x:spaceship._x, _y:spaceship._y});

2) yes. :D if (Key.isDown (KeySPACE)) { ... } maybe something similiar to this.

3) You have to create some onEnterFrame function or onClipEvent (enterFrame) on your laserProjectileMovieclip and every frame check current position (this._x and this._y) if they are not smaller than 0 (so they reached top or left corner) or if they are not greater than Stage.height/Stage.width (so they reached bottom or right corner)...

#3 Tudi

Tudi

    Young Padawan

  • Members
  • Pip
  • 42 posts

Posted 30 May 2005 - 07:42 AM

Thanks MarMar, I managed to pass the bit. :blink:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users