Very new to C++ and Cocos2d-x but I was just toying around with CCArray and had a question. I’m used to NSMutableArray and NSArray, where i dont have to set the size for the array upon creation.
with CCArray every example i find of it has the size set
CCArray *frames = CCArray::arrayWithCapacity(int)
So my question is this, is it possible to leave the capacity open ended?
Is this gonna cause problems in the future?
And can I add more elements in the future as I can do with NSMutableArray, but not NSArray.
thanks!
In cocos2d-x CCArray is mutable, i.e. you can add elements to it. To create CCArray instance without capacity, you can use
CCArray::array()constructor. CCMutableArray is template-based container that can store objects of the same type. CCArray stores objects as CCObject instances, so you have to cast them after getting from CCArray instance