Compare two variables or more

Get help using Construct 2

Post » Wed Jul 08, 2015 2:29 am

Ok, this may sound simple but I couldn't do it. Any help would be welcome!

So, I have these three objects (Target, ObjectA and ObjectB). Their frames are determined by three different variables (every tick set object frame to that variable). Each frame is a different geometric form. Example: Frame 3 is a square for all objects.

What i'm trying to do here is that every time the user presses space bar, the system compares if there are any objects that are identical. If so, then set the "ObjectIdentical" variable to 1. If not, then its 0.

There's an image explaining what i'm thinking: http://imgur.com/fe9m0TB

As Always, thank you in advance, community!
B
6
S
1
Posts: 56
Reputation: 862

Post » Wed Jul 08, 2015 3:21 am

Create a global variable for each object with the same name of the object and wright conditions for each

Target > Animation frame = 0 > System > Set Value > Target_Variable = 0
Target > Animation frame = 1 > System > Set Value > Target_Variable = 1
Target > Animation frame = 2 > System > Set Value > Target_Variable = 2
Target > Animation frame = 3 > System > Set Value > Target_Variable = 3

Object1 > Animation frame = 0 > System > Set Value > Object1_Variable = 0
Object1 > Animation frame = 1 > System > Set Value > Object1_Variable = 1
Object1 > Animation frame = 2 > System > Set Value > Object1_Variable = 2
Object1 > Animation frame = 3 > System > Set Value > Object1_Variable = 3

Object2 > Animation frame = 0 > System > Set Value > Object2_Variable = 0
Object2 > Animation frame = 1 > System > Set Value > Object2_Variable = 1
Object2 > Animation frame = 2 > System > Set Value > Object2_Variable = 2
Object2 > Animation frame = 3 > System > Set Value > Object2_Variable = 3

Then

Create a function and put the following conditions in it

System > Target_Varable = Object1_Variable > Set Value ObjectIdentical = 1
Else > (Do Nothing)

System > Target_Varable = Object2_Variable > Set Value ObjectIdentical = 1
Else > (Do Nothing)

When you press spacer bar, call the function. The default value of ObjectIdentical should be 0.

I don't know the particulars of your code but when the game resets with new animation frames to compare, you need to create or add an "Event" to set the value of ObjectIdentical variable back to 0.

I also don't think you need to use every tick. When a global variable has a value, it is always every tick.


As I just thought about it, you could just do this:

Just create the Target_Varable and write it like this:

System > Target_Varable = Object1.AnimationFrame > Set Value ObjectIdentical = 1
Else > (Do Nothing)

System > Target_Varable = Object2.AnimationFrame > Set Value ObjectIdentical = 1
Else > (Do Nothing)

Hope this helps
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Wed Jul 08, 2015 5:30 am

Image
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Wed Jul 08, 2015 11:44 pm

Got it to work!

Thank you!
B
6
S
1
Posts: 56
Reputation: 862


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 9 guests