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:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620

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:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620

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
296
S
119
G
96
Posts: 7,328
Reputation: 71,298

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
402
S
238
G
89
Posts: 24,628
Reputation: 196,023


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests