我在我的应用程序中有这个代码,byx xcode说它已被弃用。
CCMenuItemSprite *imageButton = [CCMenuItemSprite itemFromNormalSprite:[CCSprite spriteWithFile:@"button_unselected.png"] selectedSprite:[CCSprite spriteWithFile:@"button_selected.png"] disabledSprite:[CCSprite spriteWithFile:@"button_disabled.png"] target:self selector:@selector(buttonTouched:)];
我跳到定义并发现了这个:
+(id) itemWithNormalSprite:(CCNode<CCRGBAProtocol>*)normalSprite selectedSprite:(CCNode<CCRGBAProtocol>*)selectedSprite
{
return [self itemWithNormalSprite:normalSprite selectedSprite:selectedSprite disabledSprite:nil target:nil selector:nil];
}
并没有说弃用。为什么会这样?
答案 0 :(得分:1)
实际上,在cocos2d的更新版本中,某些方法的名称已被更改,因此有时xcode会为您提供该方法的弃用。
CCMenuItemSprite *imageButton = [CCMenuItemSprite itemWithNormalSprite:[CCSprite spriteWithFile:@"button_unselected.png"] selectedSprite:[CCSprite spriteWithFile:@"button_selected.png"] disabledSprite:[CCSprite spriteWithFile:@"button_disabled.png"] target:self selector:@selector(buttonTouched:)];