How do I Give priority in an overlapping?

Get help using Construct 2

Post » Wed Aug 10, 2016 6:27 pm

Hello,

I making a beat ' em up, and the hero can hold an enemy if a little sprite square, linked to the hero, overlapping with the square of the enemy.
I don't want the hero can hold two enemies in the same time, but, sometime, they're overlapping togheter ( beacause they entering in overlap in the same time ).

How can I give them the priority?

I tried to say to the software to take the closest in the coordinate X and Y, but probably something is wrong....

Thanks in advance! :)
B
4
Posts: 18
Reputation: 236

Post » Wed Aug 10, 2016 9:14 pm

@mirko26

Just add a global variable or instance variable IsHolding set to 0, then

Sprite: On collision with Enemy AND IsHolding is = 0 => set IsHolding to 1, pin Enemy to Sprite (or whatever function you have in place.)
(When you are ready to throw, drop or whatever your Enemy:)
If key is down => set IsHolding to 0

That way, it will only act on 1 Enemy at the time.
B
17
S
9
G
5
Posts: 74
Reputation: 4,145

Post » Wed Aug 10, 2016 9:32 pm

@mirko26

My bad, what I meant to say is:

Enemy: On collision (or is overlapping if you are using a mouse or keyboard input to trigger the event) with Sprite And IsHolding
sub-event Enemy: pick top instance => ....
B
17
S
9
G
5
Posts: 74
Reputation: 4,145

Post » Wed Aug 10, 2016 10:32 pm

Yesss sure! Thx!!!
B
4
Posts: 18
Reputation: 236


Return to How do I....?

Who is online

Users browsing this forum: DiegoSanudoDT and 13 guests