新手问最简单的问题。。。

新人0编程基础看看cocos2dx
我把一个按键单拉出来了,

CCMenu *HelloWorld::ppMenu3(){
    
     CCMenuItemImage *presumeItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                       this,  //就是这里的问题  具体填写什么呢
                                        menu_selector(HelloWorld::resumeGame));

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(presumeItem, NULL);
    pMenu->setPosition(ccp(300,300));
    return pMenu;
}


```




想问一下,在HELLOWORLD::INIT()里 CCMenuItemImage的target应该填this,但是我要是拉出来,再在scene里加入按键


 
CCScene* HelloWorld::scene()
{
    // 'scene' is an autorelease object
    CCScene *scene = CCScene::create();
    
    // 'layer' is an autorelease object
    HelloWorld *layer = HelloWorld::create();
    CCMenu *menu = HelloWorld::ppMenu3(); 
    // add layer as a child to scene
    scene->addChild(layer);
    scene->addChild(menu,4);
    // return the scene
    return scene;
}


```




然后......运行就会出现中断.......要是把this换成HELLOWORLD::SCENE() 结果也是有问题
请问该怎么弄


话说cocos2d的教程微微少了点

新新手路过,貌似按钮属于layer吧

嗯 但是问题是layer怎么调用呢。。。。。HELLOWORLD就是CCLAYER的类 怎么调用HELLOWORLD呢。。。

返回不了一个自动释放的局部指针

pMenu->retain();
然后再返回,不过不要忘了release()

能说的详细一些么?比如具体在按键的构架方法里 改成什么 然后调用的时候 改成什么…这个不是很理解 麻烦了

— Begin quote from ____

引用第2楼nojobs于2013-11-07 15:20发表的 回 1楼(applegreener) 的帖子 :
嗯 但是问题是layer怎么调用呢。。。。。HELLOWORLD就是CCLAYER的类 怎么调用HELLOWORLD呢。。。 http://www.cocoachina.com/bbs/job.php?action=topost&tid=166061&pid=848144

— End quote

Helloworld::create() 返回的layer就是这个this 啊,把layer指针做参数传进去

具体应该怎么写呢?

— Begin quote from ____

引用第7楼nojobs于2013-11-07 16:22发表的 回 6楼(applegreener) 的帖子 :
具体应该怎么写呢? http://www.cocoachina.com/bbs/job.php?action=topost&tid=166061&pid=848174

— End quote

CCMenu *menu = HelloWorld::ppMenu3(layer);

CCMenuItemImage *pCloseItem = CCMenuItemImage::create(        "CloseNormal.png",        "CloseSelected.png",        layer,        menu_selector(HelloWorld::resumeGame));