Cannot call member function 'bool cocos2d::CCMenuItemLabel::initWithLabel' without object

Cannot call member function 'bool cocos2d::CCMenuItemLabel::initWithLabel' without object
0.0 0



In my IntroMenu.cpp, I have got the following code:

void IntroMenu::setUpIntroMenu()
//Code here...

CCLabelTTF *coinsLabel = CCLabelTTF::labelWithString("Coins:", CCSizeMake(200.0f, 30.0f),CCTextAlignmentLeft,"Marker Felt", 23);
CCMenuItemLabel * buyCoinItem = CCMenuItemLabel::initWithLabel(coinsLabel, this,menu_selector(IntroMenu::buyCoin));// ##COMPILATION ERROR HERE##

//Code here...

void IntroMenu::buyCoin()
    //Some code...

I get the following error:

IntroMenu.cpp:504: error: cannot call member function 'bool cocos2d::CCMenuItemLabel::initWithLabel(cocos2d::CCNode*, cocos2d::SelectorProtocol*, void (cocos2d::SelectorProtocol::*)(cocos2d::CCObject*))' without object

And, for other similar cases, I have got this error:

IntroMenu.cpp: error: Semantic Issue: Call to non-static member function without an object argument

How can I solve this issue ?



buyCoin() should accept a parameter CCObject*.
So change it to buyCoin(CCObject*).


Thanks for your answer but still get the same errors. Any other idea ? Thanks for your help.


Found this issue…. My mistake was to use:

bool CCMenuItemLabel::initWithLabel(CCNode* label, SelectorProtocol* target, SEL_MenuHandler selector)

instead of:

CCMenuItemLabel * CCMenuItemLabel::itemWithLabel(CCNode*label, SelectorProtocol* target, SEL_MenuHandler selector)

So, I changed initWithLabel to itemWithLabel !