Copy link to clipboard
Copied
hey
how can i flip symbol in animate?
i want to flip the player in game when you press the left key.
the result need to be player player walk right and when i press left he turned to left.
help please?
root = this;
document.onkeydown = function(e) {
switch (e.keyCode) {
case 37: flipLeft();
break;
case 39: flipRight();
break;
}
};
function flipLeft(){
createjs.Tween.get(root.mcName).to(
{scaleX:-1},
250, createjs.Ease.elasticOut);
}
function flipRight(){
createjs.Tween.get(root.mcName).to(
{scaleX:1},
250, createjs.Ease.elasticOut);
}
Please note that mcName should be changed to match the instance name of the movie clip that you want to flip.
Also, just
...Copy link to clipboard
Copied
To flip a symbol:
Select your symbol. Go to Modify > Transform > Flip Horizontal.
Copy link to clipboard
Copied
but i want that it happen automaticlly
like in super mario
when you press right he walk right,when you press left the same mario walk left with the face to left.
//right arrow
if (e.keyCode==39){
kid.alpha=1;
/*kid2.alpha=0;*/
backR.x -=10;
kid.x +=10;
}
this is for right walk, i want that when i press left the mario turn left so i need that the flip will be in the code
Copy link to clipboard
Copied
You just set the X scale negative instead of positive.
Copy link to clipboard
Copied
how the syntax and the function will look if i in function of the parameter keycode?
Copy link to clipboard
Copied
root = this;
document.onkeydown = function(e) {
switch (e.keyCode) {
case 37: flipLeft();
break;
case 39: flipRight();
break;
}
};
function flipLeft(){
createjs.Tween.get(root.mcName).to(
{scaleX:-1},
250, createjs.Ease.elasticOut);
}
function flipRight(){
createjs.Tween.get(root.mcName).to(
{scaleX:1},
250, createjs.Ease.elasticOut);
}
Please note that mcName should be changed to match the instance name of the movie clip that you want to flip.
Also, just wanted to mention that Stack Overflow was super helpful in figuring this out: keyboard events - Detecting arrow key presses in JavaScript - Stack Overflow
Copy link to clipboard
Copied
thank you!!