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
45
S
24
G
30
Posts: 512
Reputation: 19,404

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
45
S
24
G
30
Posts: 512
Reputation: 19,404

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
270
S
98
G
70
Posts: 7,267
Reputation: 75,644

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
382
S
222
G
84
Posts: 23,984
Reputation: 189,235


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, JoshSenpai, Soulmachine, WeariedCoffee2, Yahoo [Bot] and 11 guests