平滑移动与触摸

问题描述:

我应该使用什么方法来平滑移动响应触摸的精灵? 我使用的CCMoveTo方法的持续时间和我的触摸位置是。我的精灵会移动,但它(精灵)会跳到让它跳动的位置。我想让精灵(用户可控制的一个精灵)在拖过屏幕时跟随我的手指。预先感谢您:)平滑移动与触摸

-Dustin

*编辑

- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event { 
    return YES; 
} 
- (void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event { 
    CGPoint location = [self convertTouchToNodeSpace: touch]; 
    //[player stopAllActions]; 
    //[player runAction: [CCMoveTo actionWithDuration:.1 position:location]]; 
    player.position = location; 
} 

这是该代码后,我直接设置精灵的位置。

尝试就像这个...

- (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 

    UITouch *touch = [touches anyObject]; 
    CGPoint location = [touch locationInView:[touch view]]; 
    location = [[CCDirector sharedDirector] convertToGL:location]; 
    sprite.position = location; 

} 
+0

非常感谢! – 2011-05-11 11:10:09

在touchMoved中,直接设置精灵的位置,而不是让CCMoveTo来完成它。

+0

它仍然只是跳过,我想精灵跟着我的手指。检查我的原始帖子,查看我的代码。 – 2011-05-11 01:42:08