我有以下代码使用 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];
}
精灵显示在屏幕上,我可以用手指在屏幕上拖动它,但是精灵比我的手指慢大约四分之一英寸。
我能做些什么来避免这种滞后?
谢谢,
遗传算法