Hey, I’m working on my platformer here, and I seem to have some very very basic AI going, but the problem I have is when I punch him as he walks towards me, he no longer plays his death or walking animations when he dies or moves.
http://x220.nu/pub/misc/Game_final.zip
there is the fla, the area of code where the problem is here:
badcreate = function (type, x, y) {
var nam = "bad"+badguycount;
var badguy = badguylayer.attachMovie(type, nam, badguycount);
badguy._x = x;
badguy._y = y;
badguy.en_attacked = false;
badguy.en_stance = false;
badguy.en_walking = true;
badguy.en_dead = false;
badguy.enInterval = 0;
badguy.en_health = 5;
badguy.platforms = 6;
badguy.speed = 7;
badguy.fall = 0;
badguy.fallspeed = 6;
badguy.onEnterFrame = function() {
this.fall += 2;
//walk towards if detected
if (this.en_walking == true && this.en_dead == false ) {
if (char._x<=this._x+20 && char._x>=this._x-20) {
this.gotoAndStop("en_idle");
goLeft = false;
goRight = false;
} else if (char._x<=this._x+150 && char._x>=this._x && char._y>=this._y-90 && char._y<=this._y+10) {
//right side
goRight = true;
goLeft = false;
} else if (char._x>=this._x-150 && char._x<=this._x && char._y>=this._y-90 && char._y<=this._y+10) {
//left side
goLeft = true;
goRight = false;
} else {
this.gotoAndStop("en_idle");
goLeft = false;
goRight = false;
}
}
if (goRight == true) {
this._xscale = 100;
this.gotoAndStop("en_walk");
this._x += 3;
}
if (goLeft == true) {
this._xscale = -100;
this.gotoAndStop("en_walk");
this._x -= 3;
}
if (ground.hitTest(this._x, this._y+1, true)) {
this.fall = 0;
//walking = true;
//jumping
/*if (this.jumping == false) {
jump.start(0, 0);
this.fall = -25;
this.walking = false;
}
*/
} else if (ground.hitTest(this._x, this._y+this.fall, true)) {
while (ground.hitTest(this._x, this._y+this.fall, true)) {
this.fall--;
}
this.en_walking = true;
this.en_jumping = false;
}
this._y += this.fall/2;
this._x += this.xspeed;
//check for death
if (this.en_health<=0) {
this.en_attacked = false;
this.en_dead = true;
this.gotoAndStop("en_death");
delete this.onEnterFrame;
}
if (this.hitTest(char) && attacked == false && playerIsAttacking == false && fight == false) {
hurt.start(0, 0);
attacked = true;
health -= 10;
stance = true;
} else {
if (stance) {
char.gotoAndStop("attacked");
}
}
//Character interval
if (attacked) {
charInterval++;
if (charInterval>23) {
attacked = false;
charInterval = 0;
}
} else if (attacked == false) {
walking = true;
}
//Is the enemy getting punched?
if (this.hitTest(char.attack_punch.hitCirc) && this.en_attacked == false) {
punch1.start(0, 0);
if (_root.char._xscale == -100) {
trace("-100");
blood("en_bloodsplat", char.attack_punch.hitCirc._x+char._x-65, char.attack_punch.hitCirc._y+char._y-40, -100);
} else if (_root.char._xscale == 100) {
trace("100");
blood("en_bloodsplat", char.attack_punch.hitCirc._x+char._x, char.attack_punch.hitCirc._y+char._y-40, 100);
}
this.en_attacked = true;
this.en_health--;
this.en_stance = true;
} else {
if (this.en_stance) {
this.gotoAndStop("en_attacked");
} else if (this.en_health>0) {
this.en_walking = true;
}
}
//enemy interval
if (this.en_attacked) {
this.enInterval++;
if (this.enInterval>12) {
this.en_attacked = false;
this.enInterval = 0;
}
}
};
badguycount++;
};
I hope someone can help me out with this, And If you see any other problems with the game outside of this problem, Please let me know and if possible, how to fix it. Thanks guys