This site requires JavaScript, please enable it in your browser!
Greenfoot back
Pointifix
Pointifix wrote ...

2014/2/25

UserInfo.getScore()

Pointifix Pointifix

2014/2/25

#
My simple Question is, what does UserInfo.getScore() return if i did not set it, so what does it return the first time i call it before the score was set?
erdelf erdelf

2014/2/25

#
acoording to the api 0
Pointifix Pointifix

2014/2/25

#
oh now i saw it. Get the user's score. By default, this is zero. What a stupid question sry -.- But another question, why did shrucis wrote this twice in this class?
public void saveHighscore(int score)
/* 16:   */   {
/* 17:25 */     if ((UserInfo.isStorageAvailable()) && 
/* 18:26 */       (this.player != null) && 
/* 19:27 */       ((score > this.player.getScore()) || (this.player.getInt(0) == 0)))
/* 20:   */     {
/* 21:28 */       this.player.setScore(score);
                  this.player.setInt(0, 1);
/* 22:29 */       this.player.store();
/* 23:   */     }
/* 17:25 */     if ((UserInfo.isStorageAvailable()) && 
/* 18:26 */       (this.player != null) && 
/* 19:27 */       (score > this.player.getScore()))
/* 20:   */     {
/* 21:28 */       this.player.setScore(score);
                  this.player.setInt(0, 1);
/* 22:29 */       this.player.store();
/* 23:   */     }
/* 24:   */   }
danpost danpost

2014/2/25

#
@Pointifix, either that is the way the author wanted to code it or the author re-wrote it and forgot to delete the first scripting. Anyway, if you feel that you can improve on it, by all means, do so. I myself would want to believe that the author forgot to remove the first scripting of the code (seeing that there is little to be gained by executing the code twice like this).
Pointifix Pointifix

2014/2/25

#
Im not feeling to improve this, i´m doing a HighscoreList the first time so i´m a noob in it ;) i want to learn from shrucis highscoreboard so mine will work soon ;)
You need to login to post a reply.