How do I pick the right instances to destroy

Get help using Construct 2

Post » Sun May 22, 2016 10:35 pm

Heya

So I've been making a game for my course as the last project, and I've stumbled upon a difficulty to make it so that a press / tap on the very first object that spawns after it fades, and if two of them spawn, the press / tap would only relate to the first one, and if the first one
is gone then the second, in that order.

Currently what happens is that it kills all of the objects (relevant to that type) present on that layer. I've tried
using pick by UID, and trying to assign instance variables to the objects, or using the dictionary + pick by UID. The best result I've got
was by storing their UID in the dictionary as an integer + a global variable and then picking by their UID, which resulted in just the last one being destroyed but existing objects on the layer to be ignored.

Here is a capx example (cleaned most of the things):
http://dl.dropbox.com/s/20mmvu3qdgo5fnv/LMBug1.capx

Any help will be greatly appreciated!
Last edited by Synchronize33 on Mon May 23, 2016 5:25 pm, edited 2 times in total.
B
5
S
1
Posts: 5
Reputation: 325

Post » Mon May 23, 2016 12:17 am

Changing the 'is touching' events to 'on touched' will only destroy the touched object rather than mass destroy every flashy thing in view. I had to disable the fading though to see this in action, the fading makes it irrelevant whether an object is destroyed or not, right? Will assume you are going to add future logic like re-enabling the fade-in on undestroyed objects or something, tough to work out exactly how you want your game to work. :D
B
45
S
15
G
73
Posts: 2,018
Reputation: 43,418

Post » Mon May 23, 2016 1:11 pm

Hmm actually the "is touching" is there as a placeholder for now since I want to replace it with calculating the distance of the tap on screen vs the object's origin point, but it's impossible when it doesn't refer to the right object. Though I must say that I didn't notice that at all, it makes sense now why they all die XD.

I've set up a boolean that won't let you destroy the object until it's invisible (fading animation ended), that's my intention at first, since it's a
"memory game" of some sort and you have to remember the exact location of the object that you see at first, and later when two lights or more
spawn you have to destroy them in the right order or you get no points basically. That's what I intended, so for now if you "miss" the press / tap
on the object it will give 0 points too. For that reason I chose the "is touching object" and inverted, to basically say that if there is a touch
but not on the object, 0 points.
B
5
S
1
Posts: 5
Reputation: 325

Post » Mon May 23, 2016 4:48 pm

Ya your old logic was basically saying 'if you are touching member of lightballs > destroy all lightballs'. When you update it to the on touched method which kinda reverses the event the logic now says 'on touching member of lightballs > destroy this member of lightballs'. The old logic doesn't single out the specific object being touched.
B
45
S
15
G
73
Posts: 2,018
Reputation: 43,418

Post » Mon May 23, 2016 5:22 pm

In that case, how would you say for example, On touched object give 100 points, and if touched but not on object, 0 points? You cannot invert the
"On touched object" so I was left with inverting "Is touching object", which kills them all. I mean, it wouldn't know which instance to refer to anyway, unless if the system knew which one came first, and if there's a touch somewhere on the screen, it would kill only that one and refer to the next one that spawned in order.
B
5
S
1
Posts: 5
Reputation: 325

Post » Mon May 23, 2016 5:41 pm

Image
B
45
S
15
G
73
Posts: 2,018
Reputation: 43,418

Post » Mon May 23, 2016 8:01 pm

Ah, yes I've tried using "Else" but failed, now I see why... It works much better now, thank you! Although it doesn't pick a specific instance, so it will destroy a single object after a touch begins, regardless of order.
B
5
S
1
Posts: 5
Reputation: 325


Return to How do I....?

Who is online

Users browsing this forum: NN81, TsubaRu, Yahoo [Bot] and 9 guests