Before I start, hello everyone, this is my first post, etc. I’m working on a platform game in Flash MX 2004, and so far I’ve gotten running and jumping down perfectly. Now I want my character to be able to shoot, and this is what I have so far:
In my main actions frame:
if (Key.isDown(Key.SHIFT)) {
d = d+1;
hero.goToAndStop(50);
}
Where hero is the main controller and frame 50 is a frame of him shooting. Then, on frame 50 of hero:
d += 1;
_root.fire = 1;
duplicateMovieClip(_root.bullet, "bullet" + d, d);
Where, obviously, bullet is the movie clip that I’m duplicating. Now, onto the actions frame in “bullet”:
onClipEvent (load) {
this._visible = 0;
if (_root.fire == 1) {
this._x = _root.hero._x;
this._y = _root.hero._y;
}
}
onClipEvent (enterFrame) {
if (this != _level0.bullet) {
if (_root.fire == 1) {
this._x += 5;
this._visible = 1;
}
if (this._y<0) {
this.removeMovieClip();
}
}
}
When I test this movie, when I press Shift, the hero fires but he fires way too rapidly. Is there any way to set it so that there can only be three instances of the bullet movie clip on the stage at one time, and if so, how? Any suggestions are appreciated.
Thanks. (Love the site, by the way.)