HElp with multidimensional custom array


How can i declare an array in cocos2d-x of two or more dimension containing an custom data type?




does CCDictionary meet you demand?


@Rakesh Jha
Why not use c++ multi-dimensional array? refer to
Another choice is changing multi-dimensional to map, and use CCDictionary map structure. For example,


you can change to


use just convert dimension int to a string, but this approach will reduce a little performance.


it does not provide a constructor for v 3.0 and above versions so we can’t use this array[0] format
so what is the proper solution for two dimensional array or vector
please reply fast

MyObject** array = new MyObject*[100];
for(int i = 0; i < 100; i++){
    array[i] = new MyObject[100];

That’ll produce 100x100 of class “MyObject”.

Of course you should remember about making memory free after use. CC_SAFE_FREE is easiest solution:

for(int i = 0; i < 100; i++){

If your object is Sprite, Node or any other class extending Ref class you should use Vector class which handles memory for you.