Abdul Samad
Abdul Samad

Reputation: 5918

Change button image at runtime in cocos2d

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

Upvotes: 0

Views: 951

Answers (1)

Andrew
Andrew

Reputation: 24846

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

Upvotes: 1

Related Questions