Cocos2d iphone 用触摸屏拖动精灵已移动

Cocos2d iphone 用触摸屏拖动精灵已移动,cocos2d-iphone,drag,freeze,sprite,touchmove,Cocos2d Iphone,Drag,Freeze,Sprite,Touchmove,我将Xcode与Cocos2d版本3.0一起使用 我想在屏幕上拖动精灵。我已使用以下代码成功地完成了此操作: (void) touchMoved:(UITouch *)touch withEvent:(UIEvent *)event { CGPoint touchLocation = [touch locationInNode:self]; sprite1.position=touchLocation; sprite2.position=touchLocation; sprite

我将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; 

}
然而,有时精灵会在一秒钟后停止移动。这不是一个滞后,因为他们从来没有赶上我的运动。他们只是停下来!如果我放开并再次开始移动我的触控,精灵会再次开始移动良好/有时会再次执行“冻结操作”

这是内存问题吗

好的,我肯定是记忆。我将这段代码复制到一个几乎没有精灵的简单游戏中,它工作得非常完美。

好的,我已经找到了

当我移动雪碧时,我不得不关闭手势识别器


游戏将我的TouchsMoved移动注册为刷卡,并取消TouchsMoved命令。

可能触摸离开[self boundingBox],在这种情况下,您将停止接收touchmoved事件。感谢您的回复。我认为“自我”指的是整个屏幕。我的手指当然不会离开屏幕。也许我应该把“自我”换成别的什么?我不玩飞镖:。。。如果你知道self的边界框是全屏的,那么你是对的,我没有进一步的解释。幸运的是,如果你用两个手指触摸屏幕会发生什么?位置是否可能在任何触摸之间发生冲突?两个手指没有任何效果:/似乎游戏不时停止阅读动作……我认为这是我能描述它的最好方式。