is there any possible that i can add null to CCArray? i check the CCArray source code, there is an assert line, that i can’t do that. but i want to create a container to hold my object inherits from CCObject, and in the init function, i want to create the container with some defalut value like null just for placeholder.is it possible?
in objetive-c(cocos2d) i can add object to an ccarray like this: [CCArray addObject:[NSNull null]]; how can i do that in cocos2d-x?
to add an empty ccobject is not a valid option for you?
thanks, i’m really not familiar with c++, can you show me how to create an empty ccobject?
Why don’t you create an empty CCArray?
CCArray* array = CCArray::create();
But my suggestion is you’d better use std::vector or std::map.
in fact i want to add a null object to a ccarray, but ccarray can’t do that
No, cocos2d-x does not allow adding NULL objects to it. you could create an Object that you would consider as “NULL”. Say, a CCNode object with a flag called isValidObject or something.
thanks a lot:)