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

2012/10/29

How can i use the Scoreboard?

HamburgerSV HamburgerSV

2012/10/29

#
I have found the ScoreBoard (import class). Now I want to use it, but there is my problem! If the variable "lives" from the class Robson is 0, the scoreboard shall appear and should show the variable "points" also from the class Robson. can someone help me please? thanks a lot :)
danpost danpost

2012/10/29

#
You just need to put what you wrote above in code: "if the variable "lives" from the class Robson is 0" (in the Robson class, after the value of lives decreases) if(lives == 0) "the scoreboard shall appear and should show the variable "points" also from the class Robson" addObject(new Scoreboard(points), getWorld().getWidth() / 2, getWorld().getHeight() / 2); Since the scoreboard needs the points value, we send it to the scoreboard when we create it and add it to the world. The only thing is, you need to make sure the scoreboard can except an integer value in one of its constructors. Be advised, however, the scoreboard that comes with Greenfoot versions 2.2.0 and higher is one that uses UserInfo data to display. So, if you are not using UserInfo in your scenario (without this scoreboard class), then you do not want to use this scoreboard at all. You need to either create one on your own or find one that is more in line with what you need.
You need to login to post a reply.