Picking offset sprites

Get help using Construct 2

Post » Thu Sep 05, 2013 4:51 pm

Hi all,
I suspect this is not possible, either that or I have really missed something.

I have lots of instances of the same sprite, I need to know when another instance of the same sprite is, say, 16 pixels above another (IE Y-16).

This is easy enough using the 'Is Overlapping At Offset' event, set Y to -16 and I get all the sprites with another sprite 16 pixels above them.

But is there any way of picking the sprite that is at the Y-16 offset? Using Pick Instance does not work because the picked sprites are only those with a Sprite at Y-16, not the ones at Y-16.

I realise I can have another event to look for the Y+16 sprites, but it seems really wasteful to have to do two overlap detection's when both sprites would have been found in the first event.

Any ideas?
Cheers,
RR
B
15
S
4
Posts: 35
Reputation: 2,358

Post » Fri Sep 06, 2013 9:21 am

Found a solution using Families, here is an example to illustrate:
https://dl.dropboxusercontent.com/u/15657176/FindBothInOffsetOverlap.capx

By putting the sprite in a family and then detecting offset overlap with that we get 2 picked lists, one for the sprite and one for the family.

Using FOR EACH did not work as it only picks from one object.
Using a normal FOR loop from zero to 'PickedCount' and then applying the Pick Instance event on both the sprite and family seems to get the matching pairs.

I hope this helps someone else as it was really frustrating me!
RR.
B
15
S
4
Posts: 35
Reputation: 2,358


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 15 guests