comparing instance variables

Discussion and feedback on Construct 2

Post » Tue Jan 06, 2015 10:02 am

Hi,

how do I compare the values of an instance variable for all the instances? I want to know if a certain var has the same value for all the instances.

Regards, Harry
B
4
S
1
Posts: 5
Reputation: 260

Post » Tue Jan 06, 2015 1:14 pm

Loop through the instances with a For each, checking each for the value. Set a local variable to 1 or something, if any of them are not the value required. Then after the loop check that var.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Tue Jan 06, 2015 5:39 pm

Thanks. Can you also jump out of a loop (more efficient)?
B
4
S
1
Posts: 5
Reputation: 260

Post » Tue Jan 06, 2015 10:36 pm

Use a While loop or check that variable as part of your For loop.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Tue Jan 06, 2015 11:03 pm

how do I compare the values of an instance variable for all the instances? I want to know if a certain var has the same value for all the instances.

condition

Sprite>instance variable equal...
>system: compare two values (Sprite.Count = Sprite.pickedcount)

may work.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Tue Jan 06, 2015 11:07 pm

Aphrodite wrote:how do I compare the values of an instance variable for all the instances? I want to know if a certain var has the same value for all the instances.

condition

Sprite>instance variable equal...
>system: compare two values (Sprite.Count = Sprite.pickedcount)

may work.


interesting :)
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Wed Jan 07, 2015 10:43 pm

Hi

thanks for your answers. I'm new to Construct2 and read the manual about how to implement your solutions, but couldn't get it to work. Could you send a screencapture how to set this up in an event (sheet), if possible?

Regards, Harry
B
4
S
1
Posts: 5
Reputation: 260


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 17 guests