Reputation: 1051
I am getting warning on this line stating that method actionWithTarget is deprecated. Can any one tell which alternative method can be used in cocos2dx
CCCallFunc *callBackfunc = CCCallFunc::actionWithTarget(this,
callfunc_selector(GamePlay::startTrumphetAnimation));
Thanks
Upvotes: 1
Views: 4115
Reputation: 318
If you are using COCOS2DX-3.0 or 3.14v
runAction( CallFunc::create([=]() { startTrumphetAnimation() }));
But you should write this line inside any method of GamePlay Class.
Upvotes: 0
Reputation: 2778
write function definition in this way
void GamePlay::startTrumphetAnimation(CCObject* sender) {
}
Upvotes: 0
Reputation: 21
Try this
CCCallFunc *calFunc = CCCalFunc::create(this,callfunc_selector(ClassName::methodName));
If you are using cocos2dx v3:
CallFunc *calFunc = CalFunc::create(CC_CALLBACK_1(ClassName::methodName,this));
void ClassName::methodName(Ref* sender)
{
}
Upvotes: 0
Reputation: 4552
if you are using new version of Cocos2dx ,
auto funcCallAction = CallFunc::create([=](){
// TODO: do you stuff here
startTrumphetAnimation();
});
runAction(funcCallAction);
Upvotes: 0
Reputation: 22042
Try this:
CCCallFunc *func = CCCallFunc::create(this, callfunc_selector(GameOverScene::MyFunction));
//Declare this function also
void GameOverScene::MyFunction(CCObject* sender)
{
}
Upvotes: 4