I'm creating a fish for an app that swims to random locations on the screen. Before the fish begins swimming towards the next location, it rotates to the angle between its starting point and the target point.
What I'm trying to figure out is: if (target.x < start.x)
, I need to flip the sprite horizontally.
The problem is, after I create the sprite and addChild
to the layer, I can't set the flipX
property of the sprite using [sprite setFlipX]
.
Is setFlipX locked after the sprite is added to the layer? How can I get around this? Is my only solution to animate?
To flip and preserve any previous scaling, use:
sprite.scaleX *= -1.f;
After you've done this you should not use the property sprite.scale
any more as it includes an assertion of scaleX == scaleY
.
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