oronbz 2 Report post Posted October 2, 2013 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. Quote Share this post Link to post Share on other sites
hackenstein 15 Report post Posted October 2, 2013 // Set Anchor to the center of your sprite yourSprite.anchor.setTo(.5,.5); // Invert scale.x to flip left/right yourSprite.scale.x *= -1; // Invert scale.y to flip up/down yourSprite.scale.y *= -1; 5 justgage, king, erich and 2 others reacted to this Quote Share this post Link to post Share on other sites
oronbz 2 Report post Posted October 2, 2013 // 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 Quote Share this post Link to post Share on other sites
efusien 5 Report post Posted October 16, 2014 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); Quote Share this post Link to post Share on other sites
ForgeableSum 102 Report post Posted April 12, 2015 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? Quote Share this post Link to post Share on other sites
oronbz 2 Report post Posted April 12, 2015 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. Quote Share this post Link to post Share on other sites
ForgeableSum 102 Report post Posted April 12, 2015 How do i access absolute height/width or are you saying in need to manually supply them? Quote Share this post Link to post Share on other sites
oronbz 2 Report post Posted April 13, 2015 How do i access absolute height/width or are you saying in need to manually supply them? Just use the native javascript Math.abs() function on the height/width to get their absolute values. 1 ForgeableSum reacted to this Quote Share this post Link to post Share on other sites
ForgeableSum 102 Report post Posted April 13, 2015 I didn't know there was a native function for that. Thanks! Quote Share this post Link to post Share on other sites