使用cocos2d拖动精灵会产生延迟

时间:2013-09-12 17:02:22

标签: ios cocos2d-iphone

我有以下代码使用cocos2D在屏幕上拖动精灵:

-(void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint touchLocation = [self convertTouchToNodeSpace:touch];
    CGPoint oldTouchLocation = [touch previousLocationInView:touch.view];
    oldTouchLocation = [[CCDirector sharedDirector] convertToGL:oldTouchLocation];
    oldTouchLocation = [self convertToNodeSpace:oldTouchLocation];

    CGPoint translation = ccpSub(touchLocation, oldTouchLocation);
    CGPoint newPos = ccpAdd([mySprite position], translation);
    [mySprite setPosition:newPos];
}

精灵显示在屏幕上,我可以用手指将它拖到屏幕上,但是精灵比我的手指慢了大约四分之一英寸。

我可以做些什么来避免这种滞后?

谢谢,

GA

0 个答案:

没有答案