How do I Make a Working Stamina Bar

Get help using Construct 2

Post » Mon May 23, 2016 4:51 am

Hello there, So I'm making a chasing game and I'm trying to find out why when I hold the shift key the stamina bar's width keeps getting wider instead of smaller.... Could use some help!

Thanks in regard, AfterLife
B
15
S
5
G
2
Posts: 31
Reputation: 2,002

Post » Mon May 23, 2016 8:05 am

Can you post a capx, or a picture of your events?
Image



Coming soon on Steam!
B
16
S
9
G
3
Posts: 201
Reputation: 3,460

Post » Mon May 23, 2016 11:13 am

mikehive wrote:Can you post a capx, or a picture of your events?



Here hope this works! https://onedrive.live.com/redir?resid=9 ... ile%2ccapx
B
15
S
5
G
2
Posts: 31
Reputation: 2,002

Post » Mon May 23, 2016 12:05 pm

The logic is randomly swapping between a global variable called Stamina which is always between 0-300 and a local variable on player called Stamina which keeps reducing constantly into negative amounts every tick and never recovers. The local variable seems broken, I don't see where it relates to the bar? If you set up two text boxes separately to display Global Stamina and Player Stamina every tick you can see what they're doing. Too confusing for me to look through as it just says Stamina everywhere.
B
45
S
15
G
73
Posts: 2,007
Reputation: 43,396

Post » Mon May 23, 2016 1:39 pm

plinkie wrote:The logic is randomly swapping between a global variable called Stamina which is always between 0-300 and a local variable on player called Stamina which keeps reducing constantly into negative amounts every tick and never recovers. The local variable seems broken, I don't see where it relates to the bar? If you set up two text boxes separately to display Global Stamina and Player Stamina every tick you can see what they're doing. Too confusing for me to look through as it just says Stamina everywhere.



So should i stick with the global or instance
B
15
S
5
G
2
Posts: 31
Reputation: 2,002

Post » Mon May 23, 2016 1:43 pm

Either one but make sure it's only one. If you plan to have stamina bars for enemies and other characters then using local variable would probably be best, then linking only the player stamina to the UI bar. If it's just the player that has stamina then just use a global variable. If it's still not working as intended with the global variable 'Stamina' then we can take another look.
B
45
S
15
G
73
Posts: 2,007
Reputation: 43,396

Post » Mon May 23, 2016 1:57 pm

plinkie wrote:Either one but make sure it's only one. If you plan to have stamina bars for enemies and other characters then using local variable would probably be best, then linking only the player stamina to the UI bar. If it's just the player that has stamina then just use a global variable. If it's still not working as intended with the global variable 'Stamina' then we can take another look.



So I'm new do you think you could switch it for me?
If not thats fine and thank you for the tips!
B
15
S
5
G
2
Posts: 31
Reputation: 2,002

Post » Mon May 23, 2016 2:06 pm

I can fix up the logic but it'll be later on today. If someone else fixes it in the meantime that's fine, otherwise I'll take a look.
B
45
S
15
G
73
Posts: 2,007
Reputation: 43,396

Post » Mon May 23, 2016 3:07 pm

plinkie wrote:I can fix up the logic but it'll be later on today. If someone else fixes it in the meantime that's fine, otherwise I'll take a look.



Thanks man!
B
15
S
5
G
2
Posts: 31
Reputation: 2,002

Post » Mon May 23, 2016 4:30 pm

I've done it here in 2 easy events. No need for variables in the end, it relies on the bar width only. Have a look. I've kept your old logic in there but disabled.

https://dl.dropboxusercontent.com/u/495 ... dited.capx

You MAY need to relate it to a global variable in future, it's easy to adjust, or you could still rely on the width of the bar if you wish i.e. if width=1 then show character's tired animation, reduce speed etc something like that.
B
45
S
15
G
73
Posts: 2,007
Reputation: 43,396

Next

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, el3um4s, Ryan Kocourek, TylerJS and 9 guests