oronbz

Horizontal Sprite Flip

Recommended Posts

Hello,

 

Is there any way to make a sprite flip its animation from right to left and vice versa other than making a "left" animation for every animation (this would take seconds in the animation tool, but would double up memory usage and complicates code)?

 

I've seen this in other JS engines like ImpactJS where they have "flip" property to their GameEntity which you can set to true or false.

Share this post


Link to post
Share on other sites
// Set Anchor to the center of your spriteyourSprite.anchor.setTo(.5,.5);// Invert scale.x to flip left/rightyourSprite.scale.x *= -1;// Invert scale.y to flip up/downyourSprite.scale.y *= -1;

 

Thank's man i'll check that out

Share this post


Link to post
Share on other sites

Is there a way to do it with a tween ? Looks like it's not working: we just see the result.

game.add.tween(yourSprite.scale).to ({    x: yourSprite.scale.x * -1,    y: yourSprite.scale.y * -1}, 1000, Phaser.Easing.Bounce.Out, true);

Share this post


Link to post
Share on other sites

Multiplying the scale on the x/y may achieve flipping, but it comes with some unwanted side effects. My images are showing negative widths/heights when flipped. This creates problems when positioning the image on the map. Any workarounds? 

 

I would've use the absolute values when looking at height/width to workaround this.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.