How do I pick the right instances to destroy

0 favourites
  • 7 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • 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):

    Any help will be greatly appreciated!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • 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.

  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)