...pick every object in a container from one uid?

0 favourites
  • 5 posts
From the Asset Store
Act on your instances, get/set their properties and variables only thanks to their UID. No more picking trouble! Plugin
  • How would one pick every object in a container on-hit? e.g. to flash all of the sprites of a composite object to imply damage.

    Premise:

    * Using spriter animations.

    * All sprites are members of a container, as automatically created on import.

    * Collision box has also been added to said container.

    * Collision boxes are also members of a family, which triggers the on-hit event.

    So I can pick the collision box on-hit, but how do I get from there to picking all of the sprites in its container and apply some visual effect to them?

  • As far as I understand picking one object inside a container picks all objects inside of it.

    If you want actions on the different objects in a container you have to set them seperately for each object.

    So - on collision-box hit, set arm to invisible, set body to fade, set eyes to scale 40, set feet to animation "explode"

  • Thanks for the response!

    That makes sense, but my problem is that I don't want to set individual parameters for each picked sprite on hit; rather, I want to apply one effect to all sprites in the container.

    So my game gets to the state where the collision box has picked everything in the container - how can I set an event that will affect all of those picked sprites without having to reference each one explicitly?

  • Well, I figured out a solution that's working so far using two families, one that contains all of the enemy sprites and another that contains their collision boxes. The sprites family has a collisionUID variable to store the UID of its appropriate collision box.

    <img src="https://dl.dropboxusercontent.com/u/637894/forums/pick1.png" border="0" />

    <img src="https://dl.dropboxusercontent.com/u/637894/forums/pick2.png" border="0" />

    Assigning the collision box's UID by distance using "pick nearest to" and iterating through every sprite to check which ones need the flashing effect both seem a little sloppy to me. Maybe there's a better a way? For the moment though, I'm just happy to have something that works.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Given the container instantiates all the contained objects, this is how I solved for my game:

    (container object) is flashing

    trigger once while true

    --------------------------------------------------------> (objects family) Flash

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