【问题标题】:rapid touches crash my game快速接触使我的游戏崩溃
【发布时间】:2012-10-18 00:42:05
【问题描述】:

我有一个启用触摸的 CCLayer 类和以下方法:

    -(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
    -(void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;

如果我反复快速点击 iPad 屏幕,它会崩溃——但不会到获取堆栈跟踪的地步。它只会冻结……控制台将显示:

2012-10-17 08:43:06.445 game[5432:607] cocos2d: animation stopped
2012-10-17 08:43:06.448 game[5432:607] cocos2d: animation started with frame interval: 4.00
2012-10-17 08:43:07.075 game[5432:607] cocos2d: animation stopped
2012-10-17 08:43:07.081 game[5432:607] cocos2d: animation started with frame interval: 60.00
2012-10-17 08:43:12.557 game[5432:607] cocos2d: animation stopped
2012-10-17 08:43:12.561 game[5432:607] cocos2d: animation started with frame interval: 4.00

有没有办法限制 ccTouchesBegan/ccTouchesEnded 方法的速率?如果我删除了这些事件处理程序中的所有代码,甚至会发生这种情况——只是超频繁地触发该方法的行为似乎使一切陷入困境。

【问题讨论】:

    标签: cocos2d-iphone


    【解决方案1】:

    这是否也发生在一个新的 cocos2d 项目中,只进行了触摸修改?如果是这样,请在 cocos2d 论坛上提交错误报告。

    日志似乎表明 cocos2d 正在暂停或停止,或两者兼而有之。通过设置断点检查是否正在调用 CCDirector 函数 startAnimationstopAnimationpauseresume。检查进行这些调用的调用堆栈。如果它来自您的代码,请修复它。如果没有,并且这发生在新项目中,请提交错误报告。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多