简体   繁体   中英

Cocos2D: how to tweak CCMenuItem with only one sprite?

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.

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

You could just use

[CCMenuItemSprite itemWithNormalSprite:one selectedSprite:one]

this way, nothing would happen when you select the sprite

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){}];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM