At 3/3/09 04:29 AM, Demon-Imp wrote:
i tried to target the character and clip inside with else -= but still fires right
onClipEvent(enterFrame){
if(_root.char.rightt <> "bullet"){
this._x += speed;
}else{
this._x -= speed;
}
}
First, you made an error :
onClipEvent(enterFrame){
if(_root.char.rightt <> "bullet"){
this._x += speed;
}else{
this._x -= speed;
}
}
Then, here's a simple code. Put the frame of your character facing right on the first frame, put the stop() actions and do the same on the second frame only change the way he is facing. In the bullet make it face right on the first frame and face left on the second one. Add the stop() actions to both.
Your character's instance name should be char.
Add this code to your bullet :
onClipEvent(enterFrame) {
speed = 20 //change this with your speed lol
if (_root.char._currentFrame == 1) {
this._x += speed;
this.gotoAndStop(1)
} else {
this._x -= speed;
this.gotoAndStop(2)
}
if (this._x >= 800) {
removeMovieClip(this);
duplicateMovieClip(this,"bullet",3);
this._x = _root.char._x;
this._y = _root.char._y;
} else if (this._x <= -800) {
removeMovieClip(this);
duplicateMovieClip(this,"bullet",3);
this._x = _root.char._x;
this._y = _root.char._y;
} else {
this.play();
}
}
And this code to the character :
onClipEvent(enterFrame) {
if(Key.isDown(Key.LEFT)) {
this.gotoAndStop(2)
this._x -= 10;
} else if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop(1)
this._x += 10;
}
}
There's only one problem, the bullet will change direction if you change the chars directions