Dang_Khoa Posted September 14, 2013 Share Posted September 14, 2013 Hello again, I'm using Phaser version 1.0, I tried sprite.flipX = true;andsprite.body.flipX = true;andsprite.flipped = true;but none of them works Link to comment Share on other sites More sharing options...
meanderingleaf Posted September 14, 2013 Share Posted September 14, 2013 Setting its scale to negative and positive has worked for me. Note that if you want to have it flip in a normal way, you need to set it's x-anchor to the middle first sprite.anchor.setTo(.5, 1); //so it flips around its middle sprite.scale.x = 1; //facing default direction sprite.scale.x = -1; //flipped i3Designer, arcbox, Luiz Bills and 2 others 5 Link to comment Share on other sites More sharing options...
Dang_Khoa Posted September 14, 2013 Author Share Posted September 14, 2013 Thank meanderingleaf, it worked Link to comment Share on other sites More sharing options...
faebeee Posted June 20, 2017 Share Posted June 20, 2017 Hi after using the solution //After creating a new sprite this.player.anchor.set(0.5); // inside a class that extends from the sprite this.scale.x = this.direction; // direction is either 1 or -1 I have to problem, that the physical body(using P2) is not aligned correctly with the sprite anymore. Any ideas? Link to comment Share on other sites More sharing options...
ncil Posted June 21, 2017 Share Posted June 21, 2017 On 6/20/2017 at 0:14 PM, faebeee said: Hi after using the solution //After creating a new sprite this.player.anchor.set(0.5); // inside a class that extends from the sprite this.scale.x = this.direction; // direction is either 1 or -1 I have to problem, that the physical body(using P2) is not aligned correctly with the sprite anymore. Any ideas? I'm not sure if this is part of the issue, but when setting the anchor, try this instead... this.player.anchor.setTo(0.5, 1); Link to comment Share on other sites More sharing options...
faebeee Posted June 23, 2017 Share Posted June 23, 2017 On 6/21/2017 at 7:25 PM, ncil said: I'm not sure if this is part of the issue, but when setting the anchor, try this instead... this.player.anchor.setTo(0.5, 1); Found the problem. I trimmed my spritesheet in texturepacker. Now works perfectly with setTo(0.5, 0.5) ncil 1 Link to comment Share on other sites More sharing options...
Recommended Posts