我有以下代码使用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