ActionManager priority

ActionManager priority
0.0 0


Currently I’m experimenting with Cocos2d-x and Box2d. I found a problem concerning the priority of Action Manager in relation to other sub-systems.
I’ve got the main layer which has the ‘update’ method, which in turn invokes PhysicsSystem::Update. Some physical nodes should shake on collision with each other. This is done via actions. But it appears that actions are performed at the very beginning of each frame, before any other scheduled functions. Thus each frame I shake the nodes and then call PhysicsSystem::Update which naturally overwrites the transformations done by actions.
Now here are two questions:

  1. Why the heck actions have the highest priority? Isn’t it conceptually wrong? Why aren’t actions performed after all scheduled functions?
  2. How to fix this issue without hacking Cocos2dx, since it can open Pandora’s box and cause new problems?


It seems this problem can be solved by using custom Action Manager with the lowest priority.
Anyway, any thoughts concerning this subject are still welcome.


Probably the actions should be called after the update.

A simple way to fix it is by chaning the priority in CCDirector.cpp :

_actionManager = new ActionManager();
_scheduler->scheduleUpdateForTarget(_actionManager, Scheduler::PRIORITY_SYSTEM, false);

Anyway, since we are adding better physics integration for v3.0, this is something that we will fix.

BTW, SpriteKit has these priorities:

  1. first call all update()
  2. then execute all actions
  3. then simulate physics
  4. then render the scene

Do you see something wrong with that order ?


Hi. Thanks for your respond

As I said in previous message, I’ve solved this problem with the following code:

void AppDelegate::ApplyActionManagerWithLowPriority()
    CCDirector* director = CCDirector::sharedDirector();
    CCScheduler* scheduler = director->getScheduler();
    CCActionManager* old_action_manager = director->getActionManager();
    CCActionManager* action_manager = new CCActionManager();
    scheduler->scheduleUpdateForTarget(action_manager, (std::numeric_limits::max)(), false);

Concerning suggested priorities of SpriteKit, I think that actions should be performed after the physics simulation. Moreover, maybe physics simulation should be the first in this list. In my first message I’ve described the scenario when your order won’t work properly.