Ios 如何使用CCTouchMoved在cocos2d中以速度/速度拖动CCSprite?

Ios 如何使用CCTouchMoved在cocos2d中以速度/速度拖动CCSprite?,ios,cocos2d-iphone,ccsprite,Ios,Cocos2d Iphone,Ccsprite,我有一个精灵,我想用手指在屏幕上移动它~拖动。 我想让我的精灵以速度移动,这意味着不要像我的手指那样快速移动 好像是这样的视频:(从0:12到0:53) 这是我的ccTouch代码。如何修复使其移动看起来更平滑 谢谢!!!:) 简单地返回TRUE -(BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event { return TRUE; } 及 尝试使用CCMoveTo动作以平滑移动 CGPoint translat

我有一个精灵,我想用手指在屏幕上移动它~拖动。 我想让我的精灵以速度移动,这意味着不要像我的手指那样快速移动

好像是这样的视频:(从0:12到0:53)

这是我的ccTouch代码。如何修复使其移动看起来更平滑

谢谢!!!:)

简单地返回TRUE

-(BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
    return TRUE;  
}


尝试使用CCMoveTo动作以平滑移动

CGPoint translation = ccpSub(touchLocation, oldTouchLocation);
if (CGRectContainsPoint(_car.boundingBox, touchLocation)) {
    CGPoint newPos = ccpAdd(_car.position, translation);
    id moveAction = [CCMoveTo actionWithDuration:0.5f position:newPos];
    [_car runAction:moveAction];
}

尝试使用CCMoveTo动作以平滑移动

CGPoint translation = ccpSub(touchLocation, oldTouchLocation);
if (CGRectContainsPoint(_car.boundingBox, touchLocation)) {
    CGPoint newPos = ccpAdd(_car.position, translation);
    id moveAction = [CCMoveTo actionWithDuration:0.5f position:newPos];
    [_car runAction:moveAction];
}