I have a main movieclip, inside I have placed my characer animations as individual moviclips and call the frame up on a keypress, example press the right arrow key and it will stop at the running right MC.
My problem occurs when I want to play the attack animation while running. With the Right Arrow key and Ctrl pressed, It updates that the righarrow leaeds to running MC every frame so it only jumps to the attack MC for one where as the animations goes for 8 frames.
This is the most advanced thing I have attampted with AS so go easy on me (Sorry if the code is messy):D.
Is there any way around this or does it need to be coded in a completley different way?
Any help is appreciated.
[AS]runSpeed = 8;
jumpSpeed = 25 ;
faceright = true;
keyPressed = false;
//----Set keystate to true or false
function keyState () {
keyState.onKeyDown = function () {
keyPressed = true;
}
keyState.onKeyUp = function () {
keyPressed = false;
setDirection ();
}
}
Key.addListener(keyState);
//----Face correct direction when no key is pressed
function setDirection () {
if (faceright) {
_root.ryu.gotoAndStop (“rStill”);
} else {
_root.ryu.gotoAndStop (“lStill”);
}
}
//----Run Attacks<-----THESE ONLY PLAY FOR ONE FRAME
_root.onEnterFrame = function () {
if (Key.isDown(Key.RIGHT && Key.CONTROL)) {
_root.ryu.gotoAndStop(“rRunAttack”);
faceright = true;
keyState ();
}else if (Key.isDown(Key.LEFT && Key.CONTROL)) {
_root.ryu.gotoAndStop("lRunAttack");
faceright = false;
keyState ();
}
}
//----Character movement functions
_root.onEnterFrame = function () {
if (Key.isDown(Key.RIGHT)) {
ryu._x += runSpeed;
_root.ryu.gotoAndStop(“rRun”);
faceright = true;
keyState ();
} else if (Key.isDown(Key.LEFT)) {
ryu._x -= runSpeed;
_root.ryu.gotoAndStop ("lRun");
faceright = false;
keyState ();
}if (Key.isDown(Key.SHIFT)) {
ryu._y -= jumpSpeed;
}else if (Key.isDown(Key.CONTROL)) {
if (faceright) {
_root.ryu.gotoAndStop ("rStillAttack");
}else {
_root.ryu.gotoAndStop ("lStillAttack");
}
}
}
[/AS]