CCMutableArray for VRope

CCMutableArray for VRope
0.0 0


Hello friends,
CCMutableArray is deprecated now and at certain place we can use CCArray instead of it…
I am trying to make array of VRope objects and when trying to iterate through it…it is giving error…
I have tried like this:
In HelloWorld.h:
std::vector<VRope *> *ropes;
In HelloWorld.m:
std::vector<VRope *>::iterator rope;
for(rope = ropes~~>begin;rope != ropes~~>end();++rope)
rope~~>update; //Not working
rope~~>updateSprites(); //Not working
update(CCTime) and updateSprites() are methods of VRope…

And i get error like this:
error: request for member ‘update’ in ‘rope.*gnu_cxx::normal_iterator<Iterator,Container>::operator* [with _Iterator = VRope***, _Container = std::vector<VRope>]’, which is of non-class type ’VRope

Does anybody know what should be the proper way here…

Thank you,


You can use CCARRAY_FOREACH to loop a array.
You can search it in TestCpp to check the usage.


Iterator is a pointer to an object, and your object type is VRope*, a pointer to VRope. So it is a pointer to pointer and needs to be dereferenced twice.



Thank you Minggo Zang andredaur readaur for pointing out…
I have tried both ways.In existing way and replacing (*rope)->update(dt); (*rope)->updateSprites(); is crashing at runtime exception…
And for CCArray way i am not understanding how i can take ccarray of type vrope…
Because as i have seen examples they have added objects of type ccobject…And at retrieving also ccobject and cast accordingly…
In this case i want to add custom class objects like vrope and iterate through it…


If VRope isn’t derived from CCObject you can’t use CCArray.

The code I provided should not crash if the contents of your vector is valid. Check out how VRope objects are created and how the vector is filled with them.


Thank you @redaur readur…you are right i had one problem regarding ropes creation and the ropes array was empty…Now correction given by you is working proper…
Actually i am still not able to configure how to debug cocos2dx project in eclipse thats why the problem took little longer…
Do you know how to debug code just like we do in xcode and in android project?


If you compile project for your platform you should be able to debug it. I’m using linux and compile for linux. When I see that all works I compile for android (and probably ios) and don’t need to debug it once more.


Ok i will check it for myself because I have taken very enough help from you…
For debugging i am trying to achieve like putting breakpoints and other stuffs as in ios and android traditional projects…