How do I keep my character's health the same

Get help using Construct 2

Post » Thu Nov 10, 2016 4:11 am

Hey! I've been trying to make my character's initial value, his health, stay the same after each layout change. Since at each layout change it creates a new sprite of my character, his health keeps getting back to what it was at the beginning and I don't know how to get it to work.
B
13
S
1
Posts: 16
Reputation: 563

Post » Thu Nov 10, 2016 4:21 am

You can just put a global variable in an event sheet. Before you change layouts, set the variable to your character's health. When the new layout starts, set the player's health to the variable's value.
Eh, Steve!
B
115
S
54
G
13
Posts: 113
Reputation: 16,151

Post » Thu Nov 10, 2016 4:28 am

But what's the global's initial value and am I suppose to name it something in particular?
B
13
S
1
Posts: 16
Reputation: 563

Post » Thu Nov 10, 2016 3:43 pm

global variable HP=100
(It changes during gameplay)
but you don't do anything it's global and it stays the same if you don't put different value on start of layout.
When you leave the game save the HP in local storage if needs be.
B
11
S
3
G
1
Posts: 34
Reputation: 872

Post » Thu Nov 10, 2016 11:05 pm

The name can be anything that makes sense, and the initial value should be whatever you want the character's health to be at the start of the game.


Man, I need to start using local storage for things...
Eh, Steve!
B
115
S
54
G
13
Posts: 113
Reputation: 16,151


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests