Displaying health variable on screen

Get help using Construct 2

Post » Sat Feb 15, 2014 2:11 pm

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?
B
6
S
1
Posts: 22
Reputation: 600

Post » Sat Feb 15, 2014 2:20 pm

Use a text object or spritefont. Update the text of the object whenever your score changes.
B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Post » Sat Feb 15, 2014 2:23 pm

[QUOTE=ArcadEd] Use a text object or spritefont. Update the text of the object whenever your score changes.[/QUOTE]
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?
B
6
S
1
Posts: 22
Reputation: 600

Post » Sat Feb 15, 2014 4:21 pm

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.
B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Post » Sat Feb 15, 2014 5:27 pm

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.
B
6
S
1
Posts: 22
Reputation: 600

Post » Sat Feb 15, 2014 5:30 pm

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.
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,573

Post » Sat Feb 15, 2014 5:33 pm

[QUOTE=BluePhaze] 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.[/QUOTE]
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 :)
B
6
S
1
Posts: 22
Reputation: 600


Return to How do I....?

Who is online

Users browsing this forum: el3um4s, Ryan Kocourek, TheSupreme, TylerJS, Yahoo [Bot] and 13 guests