|
-
Basic Space Shooter
I've been trying to make a pretty simple space shooting game, and I was following the tutorial over at http://www.artifactinteractive.com.a...tutorial1.html
I've tried twice, and I'm quite sure I've followed the instructions exactly as was said, but I'm still pretty new with Actionscript so I thought somebody more experienced most notice where I went wrong. Instead of the lasers firing every time you press CTRL, they go off once as soon as it starts, but not again, even if you do press CTRL.
Here's the code I have for the ship.
onClipEvent(load){
moveSpeed=10;
_root.laser._visible=false;
laserCounter=1;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.CONTROL)) {
laserCounter++;
_root.laser.duplicateMovieClip( "laser"+laserCounter, laserCounter );
_root["laser"+laserCounter]._visible=true;
}
if (Key.isDown(Key.RIGHT)) {
this._x+=moveSpeed;
} else if (Key.isDown(Key.LEFT)) {
this._x-=moveSpeed;
}
if (Key.isDown(Key.DOWN)) {
this._y+=moveSpeed;
} else if (Key.isDown(Key.UP)) {
this._y-=moveSpeed;
}
}
And for the laser movie clip.
onClipEvent (load) {
laserMoveSpeed=20;
this._y=_root.spaceship._y;
this._x=_root.spaceship._x+80;
}
onClipEvent (enterFrame) {
this._x+=laserMoveSpeed;
if (this._x>600){
this.removeMovieClip();
}
}
-
Senior Member
Make sure you have set correct instance names "spaceship" and "laser".
-
Also, just as a general rule, you really don't want to use Ctrl for things. Aside from being a context button for PC programs, within the flash player itself pressing Ctrl+left and Ctrl+right acts like a remote control for the movie, you can use it to skip frames.
Make it the spacebar or something..
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
|