PDA

View Full Version : Fla Help!! Firing Bullets!



ironzionmarley
May 22nd, 2003, 12:34 AM
Hey everyone. I have a quick question. I should know how to do this, but i am brain dead right now. I followed Kirupa's intructions and I can get my square box to shoot out a red circle. I took it further and added simple left and right key presses tom make my square move on the x axis. But whevever i shoot bullet, then move, my bullet stays ahead of my box, so my key presses control the box AND the bullet. How do I get the circle a.k.a. bullet to go in straight path in which i shot it. Pissin me off.:angry: Here is code.

=============================================

Square "Gun" Actions instance name ="gun"

on (keyPress "<Space>") {
_root.fire = 1;
_root.i += 1;
duplicateMovieClip(_root.bullet, "bullet"+i, i);
}
on (keyPress "<Left>") {
_x += -5;
}
on (keyPress "<Right>") {
_x += 5;
}

=============================================

Circle "Bullet" Actions instance name ="bullet"

onClipEvent (load) {
this._visible = 0;
if (_root.fire == 1) {
this._x = _root.crab._x;
this._y = _root.crab._y;
}
}
onClipEvent (enterFrame) {
if (this != _level0.bullet) {
if (_root.fire == 1) {
this._y -= 5;
this._visible = 1;
}
if (this._y<0) {
this.removeMovieClip();
}
}
}

=============================================

Please help me out, remember I want the bullet to go straight after i press space bar a.k.a. "fire button" and not to move along with my shooter. Thanx =)

Clown Staples
May 22nd, 2003, 01:37 AM
the problem is probably _root.fire
doublecheck that it is set to 0 and 1 at all appropriate times

Clown Staples
May 22nd, 2003, 01:39 AM
try changing duplicateMovieClip to _root.duplicateMovieClip
see what that does

ironzionmarley
May 22nd, 2003, 12:38 PM
Thanks for the help but neither of those worked. Nice try though!:)

lava
May 22nd, 2003, 01:04 PM
try using this._x instead of just _x

ironzionmarley
May 22nd, 2003, 01:46 PM
Still didnt work. Its aight though.