Cocos2d-x如何正确使用MoveTo动作来拖动精灵

时间:2014-09-08 14:33:27

标签: drag-and-drop cocos2d-x cocos2d-x-3.0

我正在使用下面的代码在垂直轴上拖动精灵。但是使用MoveTo动作让精灵跟随触摸只会让它变得疯狂,虽然只是设置位置触摸位置工作正常。

//// Move Player
// Location
touchMovedLocation = ( touch -> getLocationInView() );
touchMovedLocation = ( this -> convertToNodeSpace(touchMovedLocation) );
// Translation
touchMovedLocation = Vec2(( lift -> getPosition().x ), touchMovedLocation.y);
touchMovedLocation = ( this -> boundLiftMovement(touchMovedLocation) );
// Move
auto action = MoveTo::create(0.2f, touchMovedLocation);
( lift -> runAction(action) );
//( lift -> setPosition(touchMovedLocation) );

0 个答案:

没有答案