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

The unwritten "How do I" capx etiquette! Nearly always provide a capx of the problem you have, and try to isolate the problem and/or no capx above 10 MB. :)
B
38
S
19
G
26
Posts: 438
Reputation: 16,581

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

The unwritten "How do I" capx etiquette! Nearly always provide a capx of the problem you have, and try to isolate the problem and/or no capx above 10 MB. :)
B
38
S
19
G
26
Posts: 438
Reputation: 16,581

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
247
S
85
G
40
Posts: 7,000
Reputation: 57,805

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
359
S
214
G
72
Posts: 22,952
Reputation: 178,630


Return to How do I....?

Who is online

Users browsing this forum: Colludium and 28 guests