我试图在Cocos2d中制作游戏主菜单上的播放按钮,这是一个图像文件。我将精灵设置为playButton,图片为Play Button.png。当我运行应用程序时,它给了我一个错误,“itemFromNormalSprite:selectedSprite:target:selector。”已弃用。有人解决这个问题吗?这是我的代码:
CCMenuItem *playGameButton = [CCMenuItemSprite itemFromNormalSprite:playButton selectedSprite:playButton target:self selector:@selector(buttonTapped:)];
CCMenu *menu = [CCMenu menuWithItems:playGameButton, nil];
menu.position = ccp(size.width/2, size.height/1.5);
[self addChild:menu z:5];
答案 0 :(得分:0)
CCMenuItem *playGameButton = [CCMenuItemImage itemFromNormalImage:playButton selectedImage:playButton disabledImage:disabledPlayButton target:self selector:@selector(buttonTapped:)];
CCMenu *menu = [CCMenu menuWithItems:playGameButton, nil];
menu.position = ccp(size.width/2, size.height/1.5);
[self addChild:menu z:5];