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

Get help using Construct 2

Post » Tue Jul 30, 2013 7:12 am

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?
B
3
Posts: 6
Reputation: 189

Post » Tue Jul 30, 2013 9:08 am

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"
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jul 31, 2013 8:11 am

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?
B
3
Posts: 6
Reputation: 189

Post » Thu Aug 01, 2013 3:05 pm

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.





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.kirbyUFO2013-08-01 15:06:28
B
3
Posts: 6
Reputation: 189

Post » Sun Apr 13, 2014 2:03 am

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
B
11
Posts: 17
Reputation: 909


Return to How do I....?

Who is online

Users browsing this forum: celstrider, cgsammu, justifun, LaurenceBedford, Magistross and 13 guests