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
MY GAMES
INCOMING Classic missile base commander game:
https://www.scirra.com/arcade/action-games/incoming-20122
(Touch control or Mouse supported)

"Down", minimal gravity platformer:
https://www.scirra.com/arcade/puzzle-games/down-1276
B
20
S
5
Posts: 41
Reputation: 2,595

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.
MY GAMES
INCOMING Classic missile base commander game:
https://www.scirra.com/arcade/action-games/incoming-20122
(Touch control or Mouse supported)

"Down", minimal gravity platformer:
https://www.scirra.com/arcade/puzzle-games/down-1276
B
20
S
5
Posts: 41
Reputation: 2,595


Return to How do I....?

Who is online

Users browsing this forum: Zed2100 and 7 guests