How to Shoot bullets

4 posts

Flag Post

How can i shoot bullets from a movieclip like in the generic defense game

 
Flag Post

This example will show you how to make a very basic shooting game:

First off, you’ll need two movieclips, your gun MC and your bullet MC.

Place the gun MC on the left side of the stage, and have it facing the opposite side. Give it an INSTANCE NAME of ‘gun’.

Place the bullet MC off-stage, and have it pointed in the same direction as the gun. Give it the instance name ‘bullet’.

Click on the bullet, and give it these actions:

onClipEvent(enterFrame){

if(_name != “bullet”){

_x += 10;

if(_x > Stage.width){

this.removeMovieClip();

}

}

}

Give the gun movieclip the following actions:

onClipEvent(load){

dup = 1;

}

onClipEvent(enterFrame){

_y = root.ymouse;

if(Key.isDown(1)){

_root.bullet.duplicateMovieClip(“bullet” + dup, _root.getNextHighestDepth());

root[“bullet” + dup].x = _x;

root[“bullet” + dup].y = _y;

}

}

That should work :)

 
Flag Post

ty

 
Flag Post

if I shoot, two bullets comes out