当分数高于目前的高分时,取得高分?

时间:2017-06-15 14:25:48

标签: swift

我正在尝试创建一个if语句,当分数高于当前的高分时,该语句会获得高分。这是我的代码:

page-specific.js

每当我运行这个if scoreColorGame.score > scoreColorGame.highScore { scoreColorGame.score = scoreColorGame.highScore print(scoreColorGame.highScore) } 总是等于0.我已经检查过if语句肯定在运行,但是这个:

scoreColorGame.highScore

无效?

1 个答案:

答案 0 :(得分:0)

你永远不会改变scoreColorGame.highScore。

试试这个:

if scoreColorGame.score > scoreColorGame.highScore {
        scoreColorGame.highScore = scoreColorGame.score // SET NEW VALUE FOR scoreColorGame.highScore
        print(scoreColorGame.highScore)

    }