Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

flip symbol

New Here ,
Feb 21, 2017 Feb 21, 2017

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?

3.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Feb 21, 2017 Feb 21, 2017

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

...
Translate
Advocate ,
Feb 21, 2017 Feb 21, 2017

To flip a symbol:

Select your symbol.  Go to Modify > Transform > Flip Horizontal.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 21, 2017 Feb 21, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 21, 2017 Feb 21, 2017

You just set the X scale negative instead of positive.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 21, 2017 Feb 21, 2017

how the syntax and the function will look if i in function of the parameter keycode?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Feb 21, 2017 Feb 21, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 23, 2017 Feb 23, 2017
LATEST

thank you!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines