cocos2dx moveTo

问题:

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不变,但是最终停下来的位置错误。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值