Hi i’m working on this star wars game, and I want to make a hittest when Luke attacks the enemy mc, The frames inside enemy_mc plays.
Here’s the code Luke Has.
onClipEvent (load) {
jumpCount = 0;
jumpSpeed = 11;
jumpMaxHeight = 10;
fallspeed = 6;
runspeed = 5;
}
onClipEvent (enterFrame) {
stop();
if (Key.isDown(Key.DOWN)) {
speed = 0;
moving = false;
movingb = false;
this.gotoAndStop("crouch");
} else if (Key.isDown(Key.CONTROL)) {
speed = 0;
moving = false;
movingb = false;
this.gotoAndStop("attack");
} else if (Key.isDown(Key.LEFT)) {
speed = -runspeed;
movingb = true;
_root.maps._x -= speed;
this._xscale = -100;
this.gotoAndStop("run");
moving = true;
} else if (Key.isDown(Key.RIGHT)) {
speed = runspeed;
movingb = true;
_root.maps._x -= speed;
moving = true;
this._xscale = 100;
this.gotoAndStop("run");
} else {
movingb = true;
speed = 0;
moving = false;
this.gotoAndStop("idle");
}
if (Key.isDown(Key.SPACE) && (_root.maps.ground.hitTest(this._x, this._y, true) && movingb)) {
jumping = true;
}
if (Key.isDown(Key.SPACE)) {
jumpSpeed -= .75;
} else if (!Key.isDown(Key.SPACE)) {
jumping = false;
}
if (jumping){
gotoAndStop("jump");
if (jumpCount<=jumpMaxHeight) {
jumpCount++;
_root.maps._y += jumpSpeed;
} else if (jumpCount>jumpMaxHeight && jumpSpeed<1) {
_root.maps._y -= fallspeed;
}
}
if (!_root.maps.ground.hitTest(this._x, this._y, true) && !jumping) {
_root.maps._y -= fallspeed;
}
if (_root.maps.ground.hitTest(this._x, this._y, true)) {
jumpCount = 0;
jumping = false;
jumpSpeed = 11;
if (_root.insects.hitTest(this.jump)) {
if (vel_y<=1) {
_root.insects.gotoAndPlay("die");
_root.insects.xspeed = 0;
_root.counter.play();
vel_y = 10;
}
}
}
}