问题:
local move_event = cc.MoveTo:create(0.2,cc.p(t_pos.x,t_pos.y))
node:runAction(cc.Sequence:create(move_event))
如果这个runAction调2次,但是保持t_pos不变,最终node位置不会停在t_pos的位置。
然后cocos 对于MoveTo有一段注释
/*
Several MoveTo actions can be concurrently called, and the resulting
movement will be the sum of individual movements.
*/
大概意思就是几个move动作会依次调用,最终的结果是这些单个事件的总和,然后怎么理解这个sum呢?
直接看源码:
void MoveTo::startWithTarget(Node *target)
{
MoveBy::startWithTarget(target;
_positionDelta = _endPosition - target->getPosition3d();
}
发现MoveTo会计算一个节点当前位置和targetPosition的差值,作为moveTo动作最终停下来的位置。
比如调两次runaction,两个moveTo动作会按顺序执行,存在中间时间段两个moveTo动作同时执行的情况。就导致了t_pos不变,但是最终停下来的位置错误。