oronbz Posted October 2, 2013 Share 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. Link to comment Share on other sites More sharing options...
hackenstein Posted October 2, 2013 Share 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; Tilde, justgage, plicatibu and 2 others 5 Link to comment Share on other sites More sharing options...
oronbz Posted October 2, 2013 Author Share 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 Link to comment Share on other sites More sharing options...
efusien Posted October 16, 2014 Share 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); Link to comment Share on other sites More sharing options...
ForgeableSum Posted April 12, 2015 Share 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? Link to comment Share on other sites More sharing options...
oronbz Posted April 12, 2015 Author Share 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. Link to comment Share on other sites More sharing options...
ForgeableSum Posted April 12, 2015 Share Posted April 12, 2015 How do i access absolute height/width or are you saying in need to manually supply them? Link to comment Share on other sites More sharing options...
oronbz Posted April 13, 2015 Author Share 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. ForgeableSum 1 Link to comment Share on other sites More sharing options...
ForgeableSum Posted April 13, 2015 Share Posted April 13, 2015 I didn't know there was a native function for that. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts