Reputation: 1448
I´m starting with cocos2d for python and would like to flip a sprite among its x (or y) axis. From what I gather this should be possible with the underlying pyglet lib but I couldn´t figure out how. I tried it like this:
class Ninja(cocos.sprite.Sprite):
def __init__(self):
super(Ninja, self).__init__("Idle__000.png")
self.flip_x = True
I think there should be a flip() or transform() function somewhere, but couldn´t find anything going through cocos2d-python and pyglets sources.
How can I flip a sprite after instantiation?
Alternative approach: If I can´t flip a sprite programmatically, I´d try to just swap out the picture with an already flipped version. How would I do this then?
Upvotes: 0
Views: 714
Reputation: 124
Hi if there is not flip method on Sprite try set property scale_x or scale_y to -1. Or make Ninja Sprite with scale parameter. There is list of parameters for sprite initialization.
Upvotes: 2