How do I filter one object type into two sets of instances?

Get help using Construct 2

Post » Tue Apr 15, 2014 1:14 pm

Ok so perhaps the subject didn't quite fully explain what I'm trying to do here.

Basically, I have no problem filtering one object type down to some specific instances and then filtering another object type in the same event, and then performing an action relating only to those two sets of instances. eg:

If object type 'block' has x position greater than 100, and if object type 'block2' has x position less than 100, THEN change 'block' sprite to 'sprite 2' and change 'block2' sprite to 'sprite 2'.

In this case the action will only trigger if both conditions are true, and when it does trigger it will ONLY affect the instances of 'block' and 'block2' which were filtered by the conditions.


My problem is trying to get scenarios like the following to work:

If object type 'block' is overlapping a point 'block x, block y - 10', then check to see if 'block' has it's 'clearabove' instance variable set to 'true'. If it does then set 'block's instance variable 'clearabove' to 'true'.

As you can see my problem is that unlike in the first case, where the two instances I wish to compare and filter are of different object types (and thus would not confuse Construct 2's object filtering system), in this case I wish to retrieve the value of an instance variable relating only to instances of 'block' which meet certain conditions (which I have highlighted as 'block') and then I wish to manipulate ONLY the instances of 'block' which meet separate conditions (which I have highlighted here as 'block'.

I can't find any way to do this without Construct just treating all 'block's as one and the same and filtering them twice (once to see if they overlap the point, and another to see if their 'clearabove' instance variable is true), when really I want two separate filterings to occur. Kind of like filtering 'all people in the room' into 'girls' and 'boys', and then using the results of tests made on the girls to determine the actions that will be taken against the boys; as opposed to filtering 'all people in the room' into 'girls' and then filtering all of those into 'boys', resulting in no instances being selected at all.

Does anybody know how I can go about doing this? It's been driving me up the wall!
B
6
Posts: 14
Reputation: 380

Post » Tue Apr 15, 2014 1:26 pm

Just store that fact that the 'clearabove' flag has been set (local variable), then rather than trying to further pick below that point, you need to move back up a level and pick the non-'clearabove' blocks and then set the 'clearabove' flag.

So,
>Pick overlaps
->Pick with 'clearabove'
-->Set temp = true
->If temp=true
-->Pick not 'clearabove'
--->foreach
---->set'clearabove'
ImageImageImage
B
71
S
21
G
221
Posts: 3,649
Reputation: 124,227

Post » Tue Apr 15, 2014 1:51 pm

Thanks blackhornet, I'll give this a go. But what do you mean by 'temp'?
B
6
Posts: 14
Reputation: 380

Post » Tue Apr 15, 2014 2:10 pm

A temporary local variable.
ImageImageImage
B
71
S
21
G
221
Posts: 3,649
Reputation: 124,227


Return to How do I....?

Who is online

Users browsing this forum: NN81, plinkie, sublimate, TsubaRu and 10 guests