【发布时间】:2015-06-03 08:49:27
【问题描述】:
与我的其他工作相比,这一定非常简单。
Essential 我有一个积分系统,您可以从游戏中获得分数,然后您将获得作为宝石的分数。假设你在一轮中得了 50 分。我希望每轮每获得 10 分,宝石就为 1 分,因此在这种情况下,宝石为 5 分。
然后我很难弄清楚如何将新点添加到宝石中,而不是像高分那样替换它们。例如,在收到 5 颗宝石(如上所述)后,我再玩一轮并获得 80 分,相当于 8 颗宝石。现在我有 13 颗宝石 (5+8) 而不仅仅是 8 颗,因为它的数量新高。
感谢您的帮助!
-(void)incrementPoints {
if (!gameOverGame) {
score++;
[self runAction:scoreSound];
SKLabelNode *scoreNode = (SKLabelNode *)[self childNodeWithName:kPointsName];
NSString *scoreString;
scoreString = [NSString stringWithFormat:@"%i", score];
scoreNode.text = scoreString;
-(void)deleteScores{
[self enumerateChildNodesWithName:kScoreboardRupeeNodeName usingBlock:^(SKNode *node,BOOL *stop){
[node removeFromParent];
}];
if(score == A*10){
highscore = A;
[[AppUserDefaults sharedAppUserDefaults]setHihgscore:(int)score + highscore];
ViewController * viewController = (ViewController *) self.view.window.rootViewController;
[viewController submitToLeaderboard:(int)score];
}
scoreboardNode = [gameObjects scoreboardWithScore:(int)score andHighscore:(int)highscore];
[self addChild:scoreboardNode];
[self enumerateChildNodesWithName:kPointsName usingBlock:^(SKNode *node,BOOL *stop){
[node removeFromParent];
}];
[self die];
}
【问题讨论】:
标签: objective-c integer game-engine linear-algebra points