【问题标题】:I would like the awarded gems (high score) to represent one gem per every ten points scored我希望获得的宝石(高分)代表每获得 10 分的宝石
【发布时间】: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


    【解决方案1】:

    只需将分数记录为分数,如果 1 gem == 10 分,那么这只是一个演示问题;即不是将 85 点显示为“85”,而是绘制 8 颗宝石。即

    NSInteger numberOfGemsToDraw = self.pointsScored / 10;
    

    请注意,self.pointsScored 将使用 NSUserDefaults 保存在 Game Center 中。这是您唯一关心的与分数相关的数据。

    另请注意,任何剩余的点(即self.pointsScored % 10)都可用于绘制半完整的宝石,因此用户可以了解他们与下一个完整的宝石的距离。

    tl;dr 存储积分并展示宝石。

    【讨论】:

      猜你喜欢
      • 2015-07-16
      • 1970-01-01
      • 2019-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-13
      相关资源
      最近更新 更多