游戏因 NSLog 错误而崩溃 (cocos2d iPhone)
在我的游戏中,我在 GameLayer 中做了很多需要在 Level1 中调用的方法。我不知道为什么,但是当我单击开始时,我在控制台中收到此错误,并且游戏崩溃了。
Assertion failure in -[CCTimer initWithTarget:selector:interval:]
接下来
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Signature not found for selector - does it have the following form? -(void) name: (ccTime) dt'
我在这里上传了 GameLayer.h 和 .m: http://www.4shared .com/file/O_1utrRj/undefined.html
注意:Level1(我调用方法的地方)位于 GameLayer 中。
In my game, I made many methods in GameLayer that I need to call in Level1. I'm not sure why, but I when I click start, I get this error in the console, and the game crashes.
Assertion failure in -[CCTimer initWithTarget:selector:interval:]
followed with
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Signature not found for selector - does it have the following form? -(void) name: (ccTime) dt'
I've uploaded GameLayer.h and .m here: http://www.4shared.com/file/O_1utrRj/undefined.html
Note: Level1 (where I call the methods) is in GameLayer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您编写了对不存在的方法 moveBunnyM 的调用。当它被有效调用时,您的应用程序就会崩溃。
然而,您编写的是一个方法 moveBunnyM:(float) delta
将第 173 行替换为:
因为
您从一个名为 moveBunny 的方法调用此方法,该方法恰好采用 dt 参数
这将消除一次崩溃,但是这表明您的消息来源存在严重的逻辑问题。
建议:不要将多个 @implementation 放在同一个 .m 文件中。创建多个文件,每个类一个。 Level1应该在Level1.h中定义,并导入Cocos.h,并在Level1.m中实现,导入Level1.h。
You have written a call to a method moveBunnyM that doesn't exist. When it's effectively called, your application crashes.
What you have written however is a method moveBunnyM:(float) delta
Replace line 173:
with
since you call this method from a method called moveBunny that happens to take a dt parameter
This will eliminate one crash, but it shows that you have serious logic issues with your source.
Piece of advice: do not put several @implementation in the same .m file. Create several files, one per class. Level1 should be defined in Level1.h, with an import of Cocos.h, and implemented in Level1.m, with an import of Level1.h.