Okey my character got this script: (its lots more but yeah.. this is the trouble code).
Frame 1 = character stand still
Frame 2 = character (MC) - movement
Frame 3 = character (MC) - Jump movement
It works fine, when I press UP, he jumpes and play frame 3.
When i press left and right it plays frame 2.
When I press .. nothing, frame 1 is played.
That correct!
BUT when i press .. left + up, or right + up, it will play frame 1.
Any idea how i can make it play Frame 3 (jump) even if I press two buttons at the same time? Would be awesome if someone knew it.
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_root.player.gotoAndStop(2);
}
if (Key.isDown(Key.LEFT)) {
_root.player.gotoAndStop(2);
}
if (Key.isDown(Key.UP)) {
_root.player.gotoAndStop(3);
}
if (!Key.isDown(Key.LEFT) and (!Key.isDown(Key.RIGHT) and (!Key.isDown(Key.UP)))) {
this.gotoAndStop(1);
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
if (Key.isDown(Key.LEFT)) {
do something
} else if (Key.isDown(Key.RIGHT)) {
do something
}
_root.player.gotoAndStop(3);
} else {
if (Key.isDown(Key.RIGHT)) {
_root.player.gotoAndStop(2);
} else if (Key.isDown(Key.LEFT)) {
_root.player.gotoAndStop(2);
} else {
this.gotoAndStop(1);
}
}
}
This should solve that. but I can't guarantee if it will cause any problem for your game.
the do something is not surpose to be in the code, it means the place for you to add your actions inside. like setting a different movement speed where it's nested without having to assign the jumping again. prodigal master's code will work as well. depending on what way you want to script it.
Prodigalmaster, it did sound abit to easy with that code and it was, it did not work .. hmm
The issue is that whatever I do, when i press MORE buttons, the character FREEZE on frame 3 and wont play the MC ![]()
So in overall the code is right, it is going to frame 3 .. BUT it wont play the MC.
If i only press UP btw, it will play the MC
Maybe that is because it is repeatedly goto and stopping on frame (3) due to the key's being down. Maybe use a boolean variable e.g. isJumping = false; and when the jump animationbegins make it isJumping = true; and finally when the animation ends make isJumping = false; and therefore in the code use && in the if statement with isJumping == false
A boolean is just the name for a variable with two states. In flash this is true and false.
Just try what I said.
You know how to make a variable right?
var isJumping:Boolean = false;
(on the main timeline).
So, there are 3 frames in the player movieclip, and animation movieclips inside those frames of the player?
Did you try WitchXHunters' code without the 'do something' bit?
North America
Europe, Middle East and Africa
Asia Pacific