我将 Xcode 与 Cocos2d 3.0 版一起使用。
我想在屏幕上拖动精灵。我已经使用以下代码成功完成了此操作:
(void) touchMoved:(UITouch *)touch withEvent:(UIEvent *)event
{
CGPoint touchLocation = [touch locationInNode:self];
sprite1.position=touchLocation;
sprite2.position=touchLocation;
sprite3.position=touchLocation;
sprite4.position=touchLocation;
}
但是,有时精灵会在一秒钟后停止移动。这不是滞后,因为他们永远追不上我的动作。他们只是停下来!如果我放手并再次开始移动我的触摸,精灵会再次开始正常移动/有时会再次执行“冻结操作”。
是内存问题吗?
好的,我确定它一定是内存。我将此代码复制到一个几乎没有任何精灵的简单游戏中,它运行良好。