Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Text  (Read 1017 times)

0 Members and 1 Guest are viewing this topic.

denisa

  • Newbie
  • *
  • Posts: 2
    • View Profile
Text
« on: January 14, 2020, 03:14:16 pm »
Heii! I am trying to display a temporary text and I don't know how. I have a game in which the player has to roll some dices for maximum three times. After he rolls he has to place his points in a table. I've done that. But know I want to show him some hints. The idea is that I want to show the hints in the table when he rolls the dices, but this text has to change always when he presses the roll button and has to disappear after he chooses where to place it's points. Can you help me with an idea of how can I display that text when a button is pressed and change it when it is pressed again and delete it when he places his points.
This is the game: https://cardgames.io/yahtzee/
I want to make those numbers that appear with red in the table when you roll the dice.
Thank you!

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: Text
« Reply #1 on: January 15, 2020, 08:58:13 am »
you can achieve these condition states by introducing a boolean values in your game classes like "bool is_button_pressed;", "bool is_he_chose" ... etc;

and then let the classes that needs those boolean properties to access them. whether by a pointers to the classes or some kind of game patterns that lets the entities in a game reference each other.
 
it's an inefficient to delete/create text objects every time when the player pressed the button. better to not to draw the text and probably it needs a timer for how long text will be drawn.
however, i think your game won't has a performance issues. since, your game has a few game objects, no collision or physics involved.

in general, it's depend on your game design which class responsible about display the hint text and its life span.