Hey, I’m having a problem with a shooting script in my game. Basically I have the player1 MC and an MC with the instance bullet on my main keyframe.
Here is the code on the keyframe:
depthcounter=0
myListener = new Object();
no=1
max=20
myListener.onKeyDown = function() {
if (Key.isDown(Key.CONTROL) and no<max) {
_root.bullet.duplicateMovieClip("bullet"+depthCounter, depthCounter)
_root["bullet"+depthCounter]._x = p1._x
_root["bullet"+depthCounter]._y = p1._y
_root["bullet"+depthCounter].speed = 10
depthcounter++;
_root.no+=1
trace(no)
}else{
}
};
Key.addListener(myListener);
And here is the code us for the bullet MC:
onClipEvent(enterFrame){
if(this._x>554){
_root.no-=1
this.removeMovieClip();
}
this._x+=speed
}
If I press control before the bullet reaches the end the bullet is removed. Any ideas?