CCCallFuncO Example

CCCallFuncO Example
0.0 0


Can anyone help me with where I am going wrong trying to use CCCallFuncO.

I am trying to call:

CCCallFuncO::create(this, callfuncO_selector(DinoTroubleScene::ChangeDinoRot), trex1[0])

trex1[ 0 ] is a variable of type TrexEnemy that inherits from CCSprite (so therefore is a CCObject)
and the prototype for DinoTroubleScene::ChangeDinoRot is:

void ChangeDinoRot(TrexEnemy* enemy)

When I do this, I get an error saying:

"error C2440: 'type cast' : cannot convert from 'void (__thiscall DinoTroubleScene::* )(TrexEnemy *)' to 'cocos2d::SEL_CallFuncO'"

Any help appreciated!


You should change ‘void ChangeDinoRot(TrexEnemy* enemy)’ to ‘void ChangeDinoRot(CCObject* pObj)’, and the implementation should be

void ChangeDinoRot(CCObject* pObj)
TrexEnemy* enemy = (TrexEnemy*)pObj;


Thanks a lot.