I am new in c++ and cocos2d-x, and I have a problem.
I have a “projectile” it is CCSprite, OK, I insert it in Array:
projectile->setTag(2);
_projectiles->addObject(projectile);
But when I need it:
CCSprite* proj;
CCARRAY_FOREACH(_projectiles,proj){
CCSprite *projectile = proj;
...
I have the error about “_projectiles” have CCObject inside.
Sorry for my bad English and thancks for help!
You have to cast
projwhich is stored inCCArrayasCCObject*toCCSprite*:You can also you
dynamic_castin case you need runtime check thatprojis actually aCCSprite: