出现问题,我刚刚为 iPhone 安装了 cocos2d。
第一个问题是它无法识别任何 header ,例如 CCDirectory.h。
因此,我在项目中打开了用户搜索路径,但这样我可以导入 header 并拥有对象指针,而不会收到任何警告,但无法识别方法。
很难解释,所以看这段代码:
标题:
#import <UIKit/UIKit.h>
#import <CCMenuItem.h>
#import <cocos2d.h>
应用程序内部DidFinishLaunching:
CCMenuItem* item; // This does not give a warning, except for the "unused variable"
// But the class is recognized
[CCMenuItem setFontName: @""]; // Warning
警告是:
Class method '+setFontName:' not found (return type default to 'id')
它不识别任何其他方法,只识别 NSObject 的方法。
最佳答案
您确定您所调用的方法存在于该类中吗? CCMenuItem 不包含名为 setFontName 的静态方法。尝试将 CCMenuItem 更改为 CCMenuItemFont。
[CCMenuItemFont setFontName: @""];
关于iphone - 无法在 cocos2d 中使用导入的类方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13702185/