CCAssert to test a class type.

CCAssert to test a class type.
0.0 0


I have a function that gets a CCNode by its tag.
I want to use a CCAssert to check to see of the class type is correct.

How can I check to see if a node is of a certain class.

e.i. in c# I would use

if(mySprite is CCSprite)

Actual Code
CCNode* node = this->getChildByTag(14); //Get the object by tag
CCAssert( ], @“node os not a CCSprite” ); //Make sure its the right class (not working)


I don’t think you can do this in C++, but you could instead try a dynamic_cast<CCSprite*>(node) and verify the result against NULL. This is an expensive operation so use it sparingly.


Thanks Catalin.