How to use CCARRAY_FOREACH


#1

Hi, everyone.

I try to use CCARRAY_FOREACH this way.

since ‘spiders’ is a CCArray and ‘spider’ is a CCSprite

CCARRAY_FOREACH(spiders, spider)
{
CCLog(“do nothing”);
}

But I receive a compilation error:
Assigning to ‘cocos2d:CCSprite ’ from incompatible type ’cocos2d::CCObject

Why this is not working?

I use it this way in cocos2d-iphone and works.


#2

In CCArray elements stored as CCObject*, so you need cast your element to your type (CCSprite*).


#3

Ok, i got it, thanks for help.