How do I Only click one object at a time?

Get help using Construct 2

Post » Wed Mar 23, 2016 7:38 am

Hello all

i am making a tower defense game and the game consist of enemies clumping up against an object and attacking it
to defeat the enemies, you have to click on them reducing their lifepoints and eventually defeating them.

my problem is, when i click the enemy if they are clumped up it triggers for ALL enemies that are touching the mouse, this is bad of course because it means you can defeat 100's of enemies in a few clicks.

How can i make it so that when you click it only registers on one object and now all of them?
B
5
S
1
Posts: 88
Reputation: 653

Post » Wed Mar 23, 2016 7:40 am

Try a "for each" loop, which can be chosen in the System tab when adding a condition.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620

Post » Wed Mar 23, 2016 8:47 am

In addition to that, you may also want a stop loop action so that the event will only run on one instance of the object.
Mistakes were made.
B
52
S
26
G
109
Posts: 1,607
Reputation: 61,635

Post » Wed Mar 23, 2016 9:00 am

This would be the simplest possible way

Image

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Post » Wed Mar 23, 2016 10:54 am

And to add something else, if you are using a family for the enemies, you could access the instance on touch.
B
6
Posts: 13
Reputation: 283

Post » Wed Mar 23, 2016 1:07 pm

fm4fanAT wrote:This would be the simplest possible way


Wow, I've never thought of that, but it works! The top instance is only picked from those that are clicked.
B
30
S
14
G
6
Posts: 160
Reputation: 5,777

Post » Wed Mar 23, 2016 6:05 pm

Thanks guys!!!
These are brilliant, ill determine which one will fit best in my game.
B
5
S
1
Posts: 88
Reputation: 653


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests