I spent a day trying to hack my own Action class, but given the hurdles I've hit trying to do so, I'm hoping there's some way to work around my problem while still using the built-in (and admittedly powerful) Action class.

To wit, I need to check collision on a linear movement type Action (like MoveTo). It appears the function simply calculates a vector and increases the Node's position on that vector as time elapses. All fine.

Now, I have a collisionHandler function set up within both my Player class and my custom Move class. However, cocos2d automatically schedules actions when they're added to a Node using the runAction method. Because of this, it seems that the collisionHandler never gets called on the Move class. The code, as I imagine it updates, looks like this:

Main{ //main loop
} // all other cocos2d scheduled updates
actions->update(); // the collision doesn't get checked til next frame

Running the collision loop twice per frame must be the wrong answer. So, how do I get it so that both the objects and their actions update before the collision loop runs?


1 Answer 1


I did some more digging through the cocos2d lib files, and figured out how to substitute my own "ActionManager" class for the default one, thereby allowing me to determine when all of the Actions get updated. I haven't had any adverse side effects, as yet. Here's the implementation:

this->ActionManager = new (std::nothrow) ActionManager(); // Director will handle safe deletion

// update players, monsters, etc.
this->ActionManager->update(); // update actions
// update collision here.

Hope this helps anyone with the same issue.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .