游戏因 NSLog 错误而崩溃 (cocos2d iPhone)

发布于 2024-12-02 03:35:25 字数 611 浏览 0 评论 0原文

在我的游戏中,我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱本泡沫多脆弱 2024-12-09 03:35:25

您编写了对不存在的方法 moveBunnyM 的调用。当它被有效调用时,您的应用程序就会崩溃。

然而,您编写的是一个方法 moveBunnyM:(float) delta

将第 173 行替换为:

[ptr moveBunnyM];

因为

[ptr moveBunnyM:(float)dt]; 

您从一个名为 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:

[ptr moveBunnyM];

with

[ptr moveBunnyM:(float)dt]; 

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文