Vol*_*ort 2 xcode objective-c cocos2d-iphone ios
我的.h文件:
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "GameData.h"
#import "PROBattleScene.h"
@interface PROBattleAI : NSObject {
BattleType type;
PROBattleScene *scene;
}
-(id)initWithType:(BattleType)_type andBattleInformation:(NSMutableDictionary*)_information andScene:(PROBattleScene*)_scene;
-(void)dealloc;
@end
Run Code Online (Sandbox Code Playgroud)
但是在线上PROBattleScene *scene;我从Xcode获得了未知类型名称错误.
我在这里尝试了答案:xcode未知的类型名称,但我已经这样做了(并且不起作用).
为什么会这样?我已经导入了我的PROBattleScene.h文件,为什么不被识别?
编辑:和PROBattleScene.h要求的内容:
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "GameData.h"
#import "SimpleAudioEngine.h"
#import "PROBattleBackground.h"
#import "PROBattleAI.h"
@interface PROBattleScene : CCLayer {
NSMutableDictionary *battleInformation;
NSMutableArray *localPlayerPartyData;
PROBattleBackground *background;
CCNode *base;
PROBattleAI *enemyAI;
}
+(CCScene*)scene;
-(id)init;
-(void)loadBattleInformation;
-(void)loadBGM;
-(void)loadBackground;
-(void)loadBase;
-(void)loadEnemyAI;
-(void)beginBattle;
@end
Run Code Online (Sandbox Code Playgroud)
你有一个循环依赖.PROBattleAI导入PROBattleScene,它导入PROBattleAI,导入PROBattleScene<zomg无限循环>
@class PROBattleWhatever尽可能在标题中使用.仅导入协议定义或超类的标头.
编辑好吧,上面的措辞完全不好......并且误导.这是(我相信)发生的细节.您的PROBattleAI导入PROBattleScene,然后导入PROBattleAI,然后再次导入PROBattleScene(所有这些都在它到达任一文件中的任何代码之前).导入将暂时忽略PROBattleScene,因为它已经导入,因为文件被跳过,您将得到未定义的类型错误.
| 归档时间: |
|
| 查看次数: |
7714 次 |
| 最近记录: |