Hello Guest

Author Topic: Score as Text  (Read 3156 times)

0 Members and 1 Guest are viewing this topic.

antneel

  • Member
  • Posts: 8
    • View Profile
Score as Text
« on: November 30, 2015, 10:13:04 PM »
I am having issues with having my text render over my background image even though I add it last. Also I cannot seem to fiure out a way to have a score text update based on time. When I do it, it renders as a blob from right over itself. Thanks for any help sorry for the noobish questions.

Kyle

  • Administrator
  • Member
  • Posts: 258
    • View Profile
Re: Score as Text
« Reply #1 on: December 02, 2015, 10:20:40 AM »
Does any text work for you or does it all render as a blob?  Some text issues can be resolved by updating your video drivers.

antneel

  • Member
  • Posts: 8
    • View Profile
Re: Score as Text
« Reply #2 on: December 03, 2015, 10:47:08 AM »
Text does render but it renders behind the background even though I add it after.

Additionally when I try to set the text every second or so in the update loop it renders a blob because it tries to write over itself. (This second part is probably because I am a noob haha). I am just not sure how to go about having text reflect the score over time.

Commanderstitch

  • Member
  • Posts: 37
  • Personal Text
    • View Profile
    • commanderstitch Homepage (coming someday)
Re: Score as Text
« Reply #3 on: December 03, 2015, 08:18:27 PM »
so render once and update position on update? if it is something that needs updated have it have the ability to change to display something like a new number or letter or text if need be. There should be ways to clear and change if an update occurs without costing too much. Otherwise this is the fun ui territory that i make up stuff as i go. :D
- Commanderstitch

antneel

  • Member
  • Posts: 8
    • View Profile
Re: Score as Text
« Reply #4 on: December 03, 2015, 09:47:48 PM »
I got it to work finally but it still renders behind the background image and I do not know why. I first add background then a sprite then the text. If I remove the background then it shows up.

Do you know why this would be?

Commanderstitch

  • Member
  • Posts: 37
  • Personal Text
    • View Profile
    • commanderstitch Homepage (coming someday)
Re: Score as Text
« Reply #5 on: December 04, 2015, 07:51:12 PM »
Hi, I can confirm this works, but i haven't needed it because after i reordered the order of when i add the entities to the scene, this became unimportant. BUT if i ever needed to move layers around on the fly i can just manually change what layer they are on.

kpulver posted this in answer to my question about moving entities around via layer depth:

kpulv:

"var e = new Entity(); e.Layer = 400"
- Commanderstitch

antneel

  • Member
  • Posts: 8
    • View Profile
Re: Score as Text
« Reply #6 on: December 05, 2015, 08:28:43 PM »
This does not work because the Text class does not contain a property called layer only entities do.

Do you know another way of displaying text on top of my background entity? Any help would be great.

Kyle

  • Administrator
  • Member
  • Posts: 258
    • View Profile
Re: Score as Text
« Reply #7 on: December 08, 2015, 05:44:30 PM »
You probably want to have some sort of Entity that is managing the things you want drawn on top of your game.  Some sort of HUD or Overlay or UI type thing.  This is generally my approach:

- Make an Entity called Hud that has the Text graphic for showing the score.
- Set this Entity's layer to -10000 or something like that to ensure it's going to be on top of everything else.
- Have a method on the Hud Entity that sets the score. Something like "SetScore(100)" will do.
- To set the score text in the game now I can just do "GetEntity<Hud>().SetScore(score)"

Graphics that are added to the Scene will be below all Entities.  This might be where your problem lies.

Does that make sense?

antneel

  • Member
  • Posts: 8
    • View Profile
Re: Score as Text
« Reply #8 on: December 09, 2015, 02:37:07 PM »
Totally thank you!!