How to flip sprites horizontally in cocos2d for iphone
4 answers
If you want to flip horizontally CCNode
, you simply do:
sprite.scaleX *= -1;
(or :) sprite.scaleX = -sprite.scaleX
; if your sprite doesn't scale at all, you can do it simply:
sprite.scaleX = -1;
The class CCSprite
has methods flipX
/ flipY
that can serve your purpose. Keep in mind the following difference in behavior :
@note Flipping does not flip any of the sprites or change the anchorPoint.
If this is what you want, you should try inverting the CCNode scaleX: property
sprite.scaleX *= -1.0;
.
+8
source to share