Cocos2d中的菜单按钮

时间:2013-04-06 05:02:11

标签: ios6 cocos2d-iphone xcode4.5

我试图在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];

1 个答案:

答案 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];