How do I check for click on a part of a sprite?

Get help using Construct 2

Post » Wed Nov 26, 2014 3:59 am

Hi,
I'm looking for a way to test a condition that checks if the player clicks on an area of a sprite and destroys it (not just somewhere on the sprite).
Thought to use to sprites, one for the whole sprite and the other one will be pinned to the bigger sprite and will act as the "killing zone", but then how can I kill them both?
TNX!
B
5
S
1
Posts: 31
Reputation: 431

Post » Wed Nov 26, 2014 8:14 am

Hi @uzet1 - I would put an invisible sprite in the target location.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Wed Nov 26, 2014 8:28 am

Hi @hunderdfold , I considered this method, but my "problem" with this is how I "kill" both sprites when I hit the invisible sprite?
lets say that I have 5 enemies, for each one I have the enemy sprite and the killing zone sprite.
Each pair is created by the create object option.
How can I connect between that two when I destroy the kill sprite?
B
5
S
1
Posts: 31
Reputation: 431

Post » Wed Nov 26, 2014 8:43 am

Instance variables?
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Wed Nov 26, 2014 8:52 am

Add an instance variable to the killing zone sprite (spriteToKillUID : number)
On creation of both, KillingZoneSprite.spriteToKillUID = Sprite.UID
On KillingZoneSprite hit, pick the sprite with KillingZoneSprite.spriteToKillUID and you can do whatever you want to the associated sprite.
B
15
S
5
G
7
Posts: 876
Reputation: 5,650

Post » Wed Nov 26, 2014 9:05 am

@prorastinator tnx I'll try this!
B
5
S
1
Posts: 31
Reputation: 431


Return to How do I....?

Who is online

Users browsing this forum: Syazanie Amirin and 8 guests