开发者

Change button image at runtime in cocos2d

开发者 https://www.devze.com 2023-03-31 03:57 出处:网络
I am creating a button with CCMenuItem in cocos2d. I want the button image to be 开发者_运维技巧change whenever i tap it. Is there anyway to do that at runtime.

I am creating a button with CCMenuItem in cocos2d. I want the button image to be 开发者_运维技巧change whenever i tap it. Is there anyway to do that at runtime.

Thanks


When creating a CCMenuItemSprite you can specify normal and selected sprite. Just specify them:

CCMenuItemSprite *item = [CCMenuItemSprite itemFromNormalSprite:@"1.png" selectedSprite:@"2.png" target:self selector:@selector(foo)];
0

精彩评论

暂无评论...
验证码 换一张
取 消