Comparing Private variables of different sprites

For questions about using Classic.

Post » Wed Apr 11, 2012 3:02 am

Is there a way to compare private variables of different objects? if there is can somebody please tell me because it would reduce the amount of events I'm using by a lot.
B
9
S
3
G
1
Posts: 10
Reputation: 710

Post » Wed Apr 11, 2012 1:46 pm

Not sure what you mean here, do you mean to compare private variables of two object instances of the same base object? or between two different objects entirely?
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Sun Apr 15, 2012 2:27 am

of two different sprites entirely
B
9
S
3
G
1
Posts: 10
Reputation: 710

Post » Sun Apr 15, 2012 5:27 am

Hmm, should be able to do Sprite1.value('Value 1') Is Equal To Sprite2.value('Value2') from a System Compare condition.
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Sun Apr 15, 2012 5:32 am

[QUOTE=Mynameisjeff] Is there a way to compare private variables of different objects?[/QUOTE] There are several ways of doing this. Without knowing the purpose it is hard to tell which one is the preferable.

(objA and objB being two different sprites with a pv named "someVar" each)

1) You can use the "compare"-conditon of the system object:
+ System: objA ('someVar') Equal to objB ('someVar')
This will result to true or false but will not pick anything.

2) You may also use the "evaluate"-condition of the system object:
+ System: objA ('someVar') = objB ('someVar')
An evaluation is a calculation that results to either true or false (e.g. objA('someVar') + 12 > objB('someVar') * 2). This will also pick nothing.

3) Another way is using the sprite's "pick by comparison"-condition:
+ objA: Pick by 'someVar' Equal to objB ('someVar')
This will pick all instances of objA that match the pv of the first instance of objB

4) Also, there's a "pick by evaluation"-condition:
+ objA: Pick by 'someVar' = objB ('someVar')
Again, this picks all instances of objA that match the pv of the first instance of objB

Use the evaluation conditions whenever the comparison is more complex than a simple compare.

Have a look at the wiki, it is full of descriptions, tricks, and other useful stuff :)
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Sun Apr 15, 2012 8:33 pm

Thanks :)
B
9
S
3
G
1
Posts: 10
Reputation: 710


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 9 guests