Displaying health variable on screen

0 favourites
  • 7 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I thought I could do this by myself, but I've been strugling with the problem for 2 days now and can't seem to make it work.

    Basically, health of the main character and the monster are both kept track of by instance variables. All I want is, for example, if my character has 15HP, I want the HUD of my game to display the number 15. Once the player looses one hp and the instance variable turns to 14, I want the HP number on the HUD to also turn into 14 etc etc. How can I?

  • Use a text object or spritefont. Update the text of the object whenever your score changes.

  • Use a text object or spritefont. Update the text of the object whenever your score changes.

    By saying "Text object" you mean the "Text" thing under "General"?

    Could tell me how exactly do I make the text object update the number whenever I loose a life?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I really think you should go through the beginner tutorials here on the website first. It will probably save you from having to ask a ton of questions.

    To answer your question, yes that text object. When you go into actions on your event sheet and click on the text object, there is a set Text option. Choose that, and put your variable name as the text you want to update.

  • Well, I actually have read a couple of tutorials and made that beginers game where you have to shoot monsters, so I have an understanding oh how things work. The ting is, making my score display was the thing I failed on learning to do when I made that game.

    So, back on topic, I did what you said:

    Event: when Character's health variable is less than 14.

    Action: Set the text object PlayerHPtext to display "health" (health is the variable that keeps track of players health).

    I still get that darn problem >.< Rather than showing the number of the variable whenever my character takes a hit, it literally shows the word health on the text object. Is there some sort of way you have to express the name of the variable? Cause all I typed in is "health" for the text object to display.

  • take away the "" around the variable name. It should recognize it as a variable. If it is a global variable you just need the name, if it is an instance variable you need to put the instancename.variable name. You can also always from the event sheet instead of entering the variable name, look at the semi-transparent window that appears above it and use the to click to your variable.

    The tutorials really do cover ALL of this. So you may want to do some more of them.

  • take away the "" around the variable name. It should recognize it as a variable. If it is a global variable you just need the name, if it is an instance variable you need to put the instancename.variable name. You can also always from the event sheet instead of entering the variable name, look at the semi-transparent window that appears above it and use the to click to your variable.

    The tutorials really do cover ALL of this. So you may want to do some more of them.

    Oh my Glob, I can't believe I never noticed that transparent window that pops up!!! Thank you soo much for pointing that out! I just tested my game and it works! Thank you both, you've been a great help :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)