Cocos2D: how to tweak CCMenuItem with only one sprite?

419 Views Asked by At

how could I tweak CCMenuItemSprite to support only one sprite?

Currently I have:

[CCMenuItemSprite itemWithNormalSprite:one selectedSprite:selectedOne] 

But would like to have:

[CCMenuItemSprite itemWithNormalSprite:one] 

EDIT: I want to modify CCMenuItem to work only with one CCSprite and not two. So I need to change also the internal methods.

3

There are 3 best solutions below

4
anon_dev1234 On

You can just use the same (normal) sprite as the selected sprite. When clicked, the button will then do nothing.

1
David On

You could just use

[CCMenuItemSprite itemWithNormalSprite:one selectedSprite:one]

this way, nothing would happen when you select the sprite

2
Guru On

try this, just change colour of seleted sprite.

CCSprite *sprite1   = [CCSprite spriteWithFile:@"Button.png"];
CCSprite * sprite2  = [CCSprite spriteWithFile:@"Button.png"];
sprite2.color = ccc3(128, 128, 128);

CCMenuItemImage *itemEasyLevelImage = [CCMenuItemImage  itemWithNormalSprite:sprite1
                                                              selectedSprite:sprite2
                                                                       block:^(id sender){}];