仍在开发我的游戏,并且每个难度我都有一个“gameSpeed”,这取决于选择的难度。
但是,当尝试运行我的应用程序时,出现以下错误:
duplicate symbol _gameSpeed in:
/Users/Ashley/Library/Developer/Xcode/DerivedData/Whack-etfeadnxmmtdkgdoyvgumsuaapsz/Build/Intermediates/Whack.build/Debug-iphonesimulator/Whack.build/Objects-normal/i386/TimedGameLayer.o
/Users/Ashley/Library/Developer/Xcode/DerivedData/Whack-etfeadnxmmtdkgdoyvgumsuaapsz/Build/Intermediates/Whack.build/Debug-iphonesimulator/Whack.build/Objects-normal/i386/GameInfo.o
ld: 1 duplicate symbols for architecture i386
collect2: ld returned 1 exit status
Command /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
我只在一个位置使用 gameSpeed。
这是在这里:
[self schedule:@selector(tryPopMoles:) interval:gameSpeed];
这是在我的 TimedGameLayer.m 里面
gameSpeed 变量在我的 GameInfo.h 中
我像这样导入标题:
#import "GameInfo.h"
我的 GameInfo.h 看起来像这样:
@interface GameInfo : NSObject
+(void)setupGame:(enum GameType)type withArg2:(enum GameDifficulty)difficulty;
+(void)resetGame;
+(void)togglePause;
@end
//Game Type
enum GameType gameType;
enum GameDifficulty gameDifficulty;
//Release Version
NSString *version;
//Settings
int gameSpeed = 1.5;
//Stats
int touches = 0;
int score = 0;
int totalSpawns = 0;
//usables
bool gamePaused = FALSE;
typedef enum GameType {
GameTypeClassic = 0,
GameTypeUnlimited,
GameTypeTimed,
GameTypeExpert,
} GameType;
typedef enum GameDifficulty
{
GameDifficultyEasy = 0,
GameDifficultyMedium,
GameDifficultyHard,
} GameDifficulty;
我的 setupGame 函数(在我的 GameInfo.m 文件中)如下所示:
+(void)setupGame:(enum GameType)type withArg2:(enum GameDifficulty)difficulty
{
gameType = type;
gameDifficulty = difficulty;
switch(gameDifficulty)
{
case GameDifficultyEasy:
gameSpeed = 1.5;
break;
case GameDifficultyMedium:
gameSpeed = 1.0;
break;
case GameDifficultyHard:
gameSpeed = 0.5;
break;
}
}
我完全迷失在这里...
有任何想法吗?
谢谢