ios5cocos2d-iphoneccmenuitem

CCMenuItemImage change runtime cocos2d


I have created a menuitem using

menuItemImage=[CCMenuItemImage itemFromNormalImage:@"image_old.png" selectedImage:@"image_old.png" target:self selector:@selector(play)];

I am using below code to change the CCMenuItemImage but it isn't working. It say's incompatible pointer type sending 'CCTextured2D' to parameter of normalimage.

 [menuItemImage setNormalImage:[[CCTextureCache sharedTextureCache]addImage:@"image_new.png"]];

How to change menuItemImage runtime?


Solution

  • You can change the normalImage with the following code. I know this is not good practice but temporarily it works fine.

    [menuItemImage setNormalImage:[CCSprite spriteWithFile:@"image_new.png"]];
    

    I Hope it would work for you.