Flip CCMenuItemImage?
In 开发者_JAVA技巧Cocos2d, I can use the flipX property on CCSprites. But I don't seem to be able to do it with CCMenuItemImages... is it possible? Or do I have to use an already flipped image resource?
you cant flip the image that is added to the CCMenuItemImage
. I would recommend using CCMenuItemSprite
instead. In that case you can easily get the sprite added to the CCMenuItemSprite
and flip it:
CCMenuItemSprite *menuItem = [CCMenuItemSprite itemFromNormalSprite:normalSprite selectedSprite:selectedSprite target:self selector:@selector(aSelector)];
then when you want to access the sprite:
CCSprite *someSprite = [menuItem normalImage];
[someSprite flipX];
hope this helps
KDaker had the right idea, but the implementation wasn't quite right. Here is the code that I got to work:
CCSprite *normalSprite = [CCSprite spriteWithFile:@"yourNormalButton.png"];
CCSprite *selectedSprite = [CCSprite spriteWithFile:@"yourSelectedButton.png"];
normalSprite.flipX = TRUE;
selectedSprite.flipX = TRUE;
CCMenuItemSprite *menuItem = [CCMenuItemSprite itemFromNormalSprite:normalSprite selectedSprite:selectedSprite target:self selector:@selector(aSelector)];
精彩评论