依赖scheduler更新机制。
1.Action它通过在一段时间内对Node元素的某些属性进行插值计算。
然后依赖时间更新去更新属性。依赖step()->update()
2.Action的管理是放在ActionManager 的hash表中,通过target作为key action防止在hash 节点的数组中。
ActionManager 添加到动作队列,并通过调用startWithTarget方法绑定动作执行者。
1.当我们对CCNode 调用runAction(Action* action)的时候,动作管理类ActionManager会新的Action和对应的目标节点添加到期管理的动作类表中。
Action * Node::runAction(Action* action) {
_actionManager->addAction(action, this, !_running);
return action;
}
2.在addAction中将动作添加到动作队列之后,会调用Aciton的startWithTarget方法,来绑定动作的执行者。
void ActionManager::addAction(Action *action, Node *target, bool paused) {
tHashElement *element = nullptr;
// we should convert it to Ref*, because we save it as Ref*
Ref *tmp = target;
HASH_FIND_PTR(_targets, &tmp, element);
if (! element) {
element = (tHashElement*)calloc(sizeof(*element), 1);
element->paused = paused;
target->retain();
element->target = target;
HASH_ADD_PTR(_targets, target, element);
}
actionAllocWithHashElement(element);
ccArrayAppendObject(element->actions, action);
action->startWithTarget(target);
}
3.在Director初始化时ActionManager 就像scheduler注册了一个系统级别的回调,每帧更新update中调用step方法进行动作更新。