I only know rotation property of CCNode may have something to do with it. But I want to flip a sprite horizontally, not rotated.
The accepted answer is wrong (or outdated). What you actually should use is:
sprite.flipX=YES;
and
sprite.flipX=NO;
to reverse it
If you mean you would like to horizontally flip a CCNode
, you simply do:
sprite.scaleX *= -1;
(or: sprite.scaleX = -sprite.scaleX
); if your sprite is not scaled at all in the first place, you might do simply:
sprite.scaleX = -1;
The CCSprite
class has got a flipX
/flipY
methods that may serve your purpose. Keep in mind the following difference in behaviour, though:
@note Flipping does not flip any of the sprite's child sprites nor does it alter the anchorPoint.
If that is what you want, you should try inversing the CCNode scaleX property:
sprite.scaleX *= -1.0;
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With