variables

Get help using Construct 2

Post » Sat Apr 27, 2013 8:26 pm

How to set 4 variables to one variable?
i mean when i have four this same sprites and each sprite have variable with 25 hp
4x 25 hp give me 100 hp so this 100 should be displayed in one visible on screen variable, right?

For exapmple when first and third sprite have 20 hp Global hp variable display 90 hp
B
93
S
19
G
34
Posts: 1,840
Reputation: 27,963

Post » Sat Apr 27, 2013 8:34 pm

If I understand well, you could set an instance Variable hp, set by default to 25 for each one, and a global variable, GlobalHp, then, you set global HP to Sprite(0).hp + Sprite(1).hp + Sprite(2).hp + Sprite(3).hp, it should work, I didn't test it though
https://www.scirra.com/forum/viewtopic.php?t=152506

And that is why you shall respect the bug reports guidelines, not only giving a capx is making the bug reproductible in one click in a situation they can work with (less time wasted trying to reproduce vague instructions) but also it helps filtering false positives.

Game design is all about decomposing the core of your game so it becomes simple instructions.
B
42
S
17
G
16
Posts: 2,089
Reputation: 15,345

Post » Sat Apr 27, 2013 9:28 pm

You can use 'For each' and add the instance variable to a total variable and display that.
ImageImageImage
B
67
S
19
G
121
Posts: 3,196
Reputation: 72,879

Post » Sat Apr 27, 2013 9:40 pm

@Aphrodite almost right but i have this same sprite x4 no 'sprite1' 'sprite2' just one sprite copied four times

@blackhornet Can you explain more ?
B
93
S
19
G
34
Posts: 1,840
Reputation: 27,963

Post » Sat Apr 27, 2013 9:43 pm

[QUOTE=delgado] @Aphrodite almost right but i have this same sprite x4 no 'sprite1' 'sprite2' just one sprite copied four times
[/QUOTE]
Sprite(0) is the first instance 0 based of Sprite, the () are used to select a particular instance, as you can verify, "(" and ")" can't be used as a Object name, because of this

Sprite(0) is the object Sprite, but only the instance 0
https://www.scirra.com/forum/viewtopic.php?t=152506

And that is why you shall respect the bug reports guidelines, not only giving a capx is making the bug reproductible in one click in a situation they can work with (less time wasted trying to reproduce vague instructions) but also it helps filtering false positives.

Game design is all about decomposing the core of your game so it becomes simple instructions.
B
42
S
17
G
16
Posts: 2,089
Reputation: 15,345

Post » Sat Apr 27, 2013 9:46 pm

ImageImageImage
B
67
S
19
G
121
Posts: 3,196
Reputation: 72,879

Post » Sun Apr 28, 2013 12:23 am

@blackhornet this is what i need but How did you set wariables to " "




Anyway i edit yours capx and when i substract from sprites, text dont show substracted number

https://dl.dropboxusercontent.com/u/44710358/test.capxdelgado2013-04-28 00:24:23
B
93
S
19
G
34
Posts: 1,840
Reputation: 27,963

Post » Sun Apr 28, 2013 12:48 am

[QUOTE=delgado] @blackhornet this is what i need but How did you set wariables to " "



Anyway i edit yours capx and when i substract from sprites, text dont show substracted number

https://dl.dropboxusercontent.com/u/44710358/test.capx[/QUOTE]

That is a little problem: The text is showing the value of total

but total isn't re-calculated when a budynek is clicked, replace the "on start of layout" by an "every tick", and it will be fine (because it will be reset to 0, recalculated, and finally the display changes, before, there were no recalculating)

EDIT: you can also only recalculate when the fish is clicked, but in this case, you must assure than the value at start of layout will be good tooAphrodite2013-04-28 00:49:48
https://www.scirra.com/forum/viewtopic.php?t=152506

And that is why you shall respect the bug reports guidelines, not only giving a capx is making the bug reproductible in one click in a situation they can work with (less time wasted trying to reproduce vague instructions) but also it helps filtering false positives.

Game design is all about decomposing the core of your game so it becomes simple instructions.
B
42
S
17
G
16
Posts: 2,089
Reputation: 15,345

Post » Sun Apr 28, 2013 3:03 am

ImageImageImage
B
67
S
19
G
121
Posts: 3,196
Reputation: 72,879

Post » Sun Apr 28, 2013 1:51 pm

@blackhornet lot of work and this is it Thanks!
B
93
S
19
G
34
Posts: 1,840
Reputation: 27,963

Next

Return to How do I....?

Who is online

Users browsing this forum: GUN and 15 guests