hy
i am trying to make a character punch and kick, i have the code to work but when i enter the movement code in and then try to press 1 and 2, nothing happens, the actions are cancelling each other out or they are having an effect on each other but i still cant find a way to fix it, here is my code
walkspeed = 5;
walk = true;
up = 38;
down = 40;
backward = 37;
forward = 39;
punchcombo = 49; // keyboard 1 for punch combo
kick= 50; // keyboard 2 for kick
jumpkey = 51;// keyboard 3 for jump
function movement () {
moving = false;
if(Key.isDown(Key.RIGHT)){
hero._x += walkspeed;
hero._xscale = 100;
moving = true;
}
if(Key.isDown(Key.LEFT)){
hero._x -= walkspeed;
hero._xscale = -100;
moving = true;
}
if(Key.isDown(Key.UP)){
hero._y -= walkspeed;
moving = true;
}
if(Key.isDown(Key.DOWN)){
hero._y += walkspeed;
moving = true;
}
if(!moving && !attacks) {
hero.gotoAndStop("stance")
}
function attacks() {
if(hero.attack)
return;
if (Key.isDown(punchcombo)) {
hero.gotoAndStop("punch"); // if there's no combo, then the normal attack is played
hero.attack = true;
}
if (Key.isDown(kick)) {
hero.gotoAndStop("kick");
hero.attack = true;
}
}
};
//------------------------
onEnterFrame = function () {
//trace(Key.getCode());
movement();
attacks();
};
and also heres my fla and swf
http://www.swfupload.com/view/104612.htm - swf
http://www.sendspace.com/file/ib7nns- fla
thanks in advance =)