Check value of instance variable in overlapped instance

Get help using Construct 2

Post » Sat Mar 08, 2014 10:45 pm

Hi!

I'm trying to wrap my head around instance variables.

I have ten instances of an object. Each of the instances have a unique instance variable. I would like to compare the value of the instance object overlapped by the player to a global variable.

How do I capture "this", or in other words how can I set it up so that the instance variable being compared is the one being overlapped?

Here's what I tried:

player Is overlapping myInstance
and myInstance.myInstanceVariable > globalVariable -->do stuff

But nothing happened so I think I'm failing to compare the correct instance here. In javascript I would call it "this".

In a nutshell:
How can I compare the instance variable value of the instance currently overlapped by the player?
B
9
S
1
Posts: 97
Reputation: 715

Post » Sat Mar 08, 2014 11:35 pm

B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Sun Mar 09, 2014 12:08 am

Thank you very much, it works!

Would it be correct to summarize that the key to using instance variables in this case was to deploy sub-events?
B
9
S
1
Posts: 97
Reputation: 715

Post » Sun Mar 09, 2014 7:34 pm

nah

you can also do it like this:

https://dl.dropboxusercontent.com/u/2560922/mobiledev/forum/overlappingObject2.capx

I just like the sub for the overview :)
B
20
S
6
G
4
Posts: 347
Reputation: 4,451


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, ignaciosimo and 13 guests