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
40
S
20
G
27
Posts: 453
Reputation: 17,261

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
40
S
20
G
27
Posts: 453
Reputation: 17,261

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
258
S
90
G
48
Posts: 7,084
Reputation: 62,904

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
367
S
217
G
82
Posts: 23,264
Reputation: 183,858


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 0 guests