iphone – 为什么检测触摸越来越慢?

在我的游戏中,如果我多次玩特定游戏,我的触摸需要更多时间来检测.

它存储所有触摸,然后同时应用这些触摸.

谁能告诉我这是什么问题?

在touchesBegan我写道:

if (CGRectContainsPoint([tapView frame], [touch locationInView:self])
    && tapView.alpha == 1) {
    [self callTapCode];
}

这是touchesEnded的代码.如果我敲击并释放敲击它显示一个敲击事件.

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    if (checkTap == TRUE && tapView.alpha == 1 )
        tap_effect_view.alpha = 0;
}

- (void)callTapCode {
    // Move player code by 6 pixels
    // not possible to write all code
}

在tapView中我不断点击. callTapCode将播放器移动六个像素.但过了一段时间后,我的触摸检测得很慢,所以玩家看起来像是在四处跳跃.我连续玩了15到16次游戏.

最佳答案 您可以通过此
tutorial来学习如何使用泄漏仪器.这是Xcode随附的Instruments套件的一部分,它将帮助您跟踪应用程序的内存泄漏和一般性能问题.

点赞