clicking is triggering multiple actions, why?

Get help using Construct 2

Post » Thu Feb 27, 2014 6:12 pm

I have a 'game field' sprite object that is in the background layer.

I also have a 'cat' sprite object placed within the 'game field' area.

When I click the 'game field' I want a new instance of 'cat' created at the point of click. (I got that working)

If I click a 'cat' instance, I want that instance deleted.

As it it, when I click a cat object, it just adds another cat on top of the previous cat object.

Image
B
3
Posts: 4
Reputation: 183

Post » Thu Feb 27, 2014 7:22 pm

You have on clicked on the playfield and the button, since they both overlap you are getting both clicks most likely...

Or, you need to have something in your logic saying don't do it under certain circumstances. For example placing the object should only work when a variable like "placeable" is true, then when you place the object set placeable back to false so that it doesn't keep happening.
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,603

Post » Thu Feb 27, 2014 8:42 pm

so how so you pick an object if this isnt the way to do it? Theres a few posts that mention this, but none that really cover a technique and explain it.

as an aside...

I think 'click selected object' action only tests whether a click is within a square. It dosent seem to have any understanding of what object is being clicked on (should be the topmost one), only that mouse.x and mouse.y are within some defined area.
B
3
Posts: 4
Reputation: 183

Post » Thu Feb 27, 2014 9:30 pm

If you have more than one object with an on-click event assigned to it, and those objects are overlapping, then you trigger the on-click for each of them.

So you may want to do something like this:

On-Clicked Playfield and as an additional condition Not-Clicked Turret1 (Use the invert option for that)
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,603

Post » Thu Feb 27, 2014 9:39 pm

ahhhh interesting, will give that a try, ty
B
3
Posts: 4
Reputation: 183


Return to How do I....?

Who is online

Users browsing this forum: max2612 and 6 guests