Scoreboard

I am working with a modified version of War Battles. I have made two players that you can control in the game. The two players try to kill each other. I want to make a scoreboard that reacts to the deaths and gives one of the players a visible point at the top of the screen. Does anyone know any code to get this working?

Yes. It’s in this tutorial: https://www.defold.com/tutorials/side-scroller/

As @sicher noted, the tutorial he linked contains what you need.

To get you thinking in terms of Defold, it could be good to get an idea of what a scoreboard actually would be, in terms of how you would implement it in Defold. One basic such scoreboard would be the following:

  1. If a death is detected, then pass a message to the GUI that a death has occurred.
  2. In the GUI script, update the score, by, for example, incrementing a “death value”, and update the way the GUI nodes corresponding to the score look like correspondingly.

That’s it. Message passing is a core concept in Defold, and should be used in essentially all cases when information needs to be transmitted from script to script.

3 Likes