我正在使用cocos2d开发一款适用于iPad的游戏,其中包含一块充满不同类型瓷砖的电路板.我创建了一个自定义类,称为Tile
tile的通用模板,Tile
其中一些子类具有不同的属性和方法.我还创建了一个类Board
,其中包括使用特殊坐标系跟踪所有切片的位置.
出于某种原因,在Board
类中,编译器似乎没有被识别Tile
为一种对象,即使我已经添加#import "Tile.h"
在文件的顶部.
这是相关的代码(只是询问是否有你想看的代码的其他部分):
Tile.h
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "Board.h"
@interface Tile : NSObject
-(void) updateNeighbors;
@property (nonatomic, retain) CCSprite* sprite;
@property (assign) CGPoint coords;
@property (assign) CGPoint positionInPoints;
@property (nonatomic, retain) NSMutableArray *neighbors;
@end
Run Code Online (Sandbox Code Playgroud)
Board.h
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "Tile.h"
@interface Board : NSObject
+(Board*)sharedBoard;
- (void) putTile: (Tile*) tile AtIndex: (CGPoint) index; //<-- error here!
- (void) replaceTileAtIndex: (CGPoint) index1 WithTileAtIndex: (CGPoint) index2;
- …
Run Code Online (Sandbox Code Playgroud) 在这个头文件中,我收到错误:未知类型名称 uint32、uint16。我是 Objective-C 的新手,我正在尝试在 Xcode 中导入一个项目。由于上述问题,构建失败。谷歌没有帮助。尝试添加/stdint/stdint.h
头搜索路径(xcode 未知类型名称, 未知类型名称'uint8_t',MinGW,Xcode - 如何将 c 库和头文件包含到可可项目中?)。构建仍然失败。
/*-------------------------------------------------------------------------
*
* block.h
* POSTGRES disk block definitions.
*
*
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/storage/block.h,v 1.26 2010/01/02 16:58:08 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef BLOCK_H
#define BLOCK_H
/*
* BlockNumber:
*
* each data file (heap or index) is divided …
Run Code Online (Sandbox Code Playgroud) 我的.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)