Ok making a fighting game with some mates. i want it to like punch normaly, punch in the air and punch when crouching. it works normally and on jumping but doesnt work with crouching. heres the code:
onClipEvent (load) {
speed = 5;
facing = "left";
onFloor = true;
crouch = false;
jump = false;
punch = false;
kick = false;
}
onClipEvent (enterFrame) {
// Movement and turning to face enemy //
if (crouch == false) {
if (Key.isDown(Key.LEFT)) {
if (onFloor == true) {
this.gotoAndStop("walking");
}
if (facing == "left") {
this._x -= speed;
} else {
this._x -= speed/1.5;
}
}
if (Key.isDown(Key.RIGHT)) {
if (onFloor == true) {
this.gotoAndStop("walking");
}
if (facing == "right") {
this._x += speed;
} else {
this._x += speed/1.5;
}
}
}
if (this._x>_root.CPU._x) {
facing = "left";
this._xscale = -100;
} else if (this._x<_root.CPU._x) {
facing = "right";
this._xscale = 100;
}
if (!Key.isDown(Key.LEFT) && !Key.isDown(Key.RIGHT) && onFloor == true) {
this.gotoAndStop(1);
}
// Basic attacks //
if (Key.isDown(68)) {
kick = true;
} else {
kick = false;
}
if (Key.isDown(65)) {
punch = true;
}else {
punch = false;
}
if (Key.isDown(87)) {
jump = true;
}else {
jump = false;
}
if (Key.isDown(83)) {
crouch = true;
}else {
crouch = false;
}
// act on the attacks //
if(punch == true && crouch == false && onFloor == true){
this.gotoAndStop("punch");
}
if(punch == true && crouch == true && onFloor == true && kick == false){
this.gotoAndStop("crouch punch");
}
if(punch == true && crouch == false && onFloor == false){
this.gotoAndStop("jump punch");
}
if(kick == true && crouch == false && onFloor == true){
this.gotoAndStop("kick");
}
if(kick == true && crouch == true && onFloor == true){
this.gotoAndStop("crouch kick");
}
if(kick == true && crouch == false && onFloor == false){
this.gotoAndStop("jump kick");
}
if(kick == false && crouch == true && onFloor == true){
this.gotoAndStop("crouch");
}
if(punch == false && crouch == true && onFloor == true){
this.gotoAndStop("crouch");
}
if(kick == false && crouch == false && onFloor == true && jump == true){
this.gotoAndStop("jump");
}
if(punch == false && crouch == false && onFloor == true && jump == true){
this.gotoAndStop("jump");
}
}
any ideas why its not working#? thnaks in advance