Expression for this?

Get help using Construct 2

Post » Wed Dec 21, 2011 6:50 am

Is there a system expression for accessing the "current" value of a global or local variable? No, not the value initially when the first layout is run. I mean accessing the current value when an event is run.

Because, I made a HP bar using a global variable, some expressions and and width adjustments via events every tick. I only came across one bug from 20 minutes of testing:
Player starts out in layout one.
Player takes damage.
Player moves to layout two, via portal; HP bar doesn't change.
Player moves back to layout one via same portal; HP bar suddenly becomes empty.

My capx file
Zelda Gamekit (my project)



Example capxs I have made:

Zelda-Style Inventory

Zelda Hearts System
B
40
S
20
G
30
Posts: 487
Reputation: 18,829

Post » Wed Dec 21, 2011 7:47 am

Fixed the bug, but I still like to know if such an expression exists.
Zelda Gamekit (my project)



Example capxs I have made:

Zelda-Style Inventory

Zelda Hearts System
B
40
S
20
G
30
Posts: 487
Reputation: 18,829

Post » Wed Dec 21, 2011 7:48 am

Variables in the manual

Extract from the how do I FAQ

[quote]
Variables (Local/Global/Instances)


    Using local variables - LINK
    More about local variables - LINK
    Using global variables - LINK[/quote]

Also in your case, the problem doesn't come from variables.
It's rather the display of the health bar that's the issue I think.

Several solutions exists. For now I'd go with the global property.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
263
S
93
G
56
Posts: 7,183
Reputation: 67,660

Post » Wed Dec 21, 2011 3:24 pm

@LaDestitute, the name of a variable in an expression gets its current value, I think you must be confused somehow...
Scirra Founder
B
373
S
218
G
84
Posts: 23,573
Reputation: 186,458


Return to How do I....?

Who is online

Users browsing this forum: KreKre, MikaelS, ninepixels, oddreal, Yasharitsu and 9 guests