【发布时间】:2015-03-12 00:07:15
【问题描述】:
我正在创建一个迷你 iOS 游戏,以让我接触 Objective C。无论如何,我有一个工作原型和一个有点功能的 HUD。它显示分数、行进距离和玩家之前的高分。但是,我无法确定玩家还剩多少生命。有人可以帮助我或为我指出正确的方向吗?任何帮助表示赞赏。提前感谢您的帮助。
这是我的生活代码和 HUD,如果需要,我会提供更多。
- (void)startTheGame{
_lives = 3;
double curTime = CACurrentMediaTime();
_gameOverTime = curTime + 30.0;
_nextAsteroidSpawn = 0;
_gameOver = NO;
for (SKSpriteNode *asteroid in _asteroids) {
asteroid.hidden = YES;
}
for (SKSpriteNode *laser in _shipLasers) {
laser.hidden = YES;
}
_ship.hidden = NO;
//reset ship position for new game
_ship.position = CGPointMake(self.frame.size.width * 0.1, CGRectGetMidY(self.frame));
//setup to handle accelerometer readings using CoreMotion Framework
[self startMonitoringAcceleration];
_highscore.text = [NSString stringWithFormat:@"High: %li pt", [RWGameData sharedGameData].highScore];
_score.text = @"0 pt";
_distance.text = @"";
lives.text = @" 3";
}
HUD:
-(void)setupHUD{
_score = [[SKLabelNode alloc] initWithFontNamed:@"Futura-CondensedMedium"];
_score.fontSize = 12.0;
_score.position = CGPointMake(50, 7);
_score.fontColor = [SKColor blackColor];
[self addChild:_score];
_distance = [[SKLabelNode alloc] initWithFontNamed:@"Futura-CondensedMedium"];
_distance.fontSize = 12.0;
_distance.position = CGPointMake(115, 7);
_distance.fontColor = [SKColor cyanColor];
[self addChild:_distance];
_highscore = [[SKLabelNode alloc] initWithFontNamed:@"Futura-CondensedMedium"];
_highscore.fontSize = 12.0;
_highscore.position = CGPointMake(200, 7);
_highscore.fontColor = [SKColor redColor];
[self addChild:_highscore];
lives = [[SKLabelNode alloc] initWithFontNamed:@"Futura-CondensedMedium"];
lives.fontSize = 12.0;
lives.position = CGPointMake(250, 7);
lives.fontColor = [SKColor yellowColor];
[self addChild:_lives];
}
【问题讨论】:
-
到底是什么问题?你似乎在做其他所有事情。
-
@sangony 我不断收到错误 Parse issue Expected identifier in my life lost function.
标签: ios objective-c iphone sprite-kit