Spriter and C2 questions

Discussion and feedback on Construct 2

Post » Wed May 21, 2014 5:44 pm

I am attempting to make the enemies in my game light up when they're hit. At any time, there are multiple instances on the screen. If I use the family of sprites to make the changes, it affects all of the zombies on the screen and not just the one I want it to. Does anyone know how to work around this?
Image
B
20
S
4
Posts: 382
Reputation: 3,004

Post » Wed May 21, 2014 5:54 pm

If i'm understanding the question correctly. Shouldn't the family object take care of this already...?

Condition: on EnemyFamily "Hit" (Picks the object in the family that was hit)
Action: EnemyFamily "Light Up" (should only affect the enemy in the family that was hit)
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Wed May 21, 2014 5:56 pm

Yes but there are multiple instances of the same family of sprites on screen at the same time. It makes all of that family light up, meaning all of them. See what I mean?
Image
B
20
S
4
Posts: 382
Reputation: 3,004

Post » Wed May 21, 2014 6:04 pm

If your condition On Collision with EnemyFamily it will pick the sprite in the family that had the collision. so the action should only affect that sprite and not all of them. Can you post a screen shot of the condition action so I can see what you have?

Check out manual entry for families. Seems like what your asking for is show here: https://www.scirra.com/manual/142/families
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Wed May 21, 2014 6:14 pm

A Spriter character is composed of multiple images and a Spriter object. The object is invisible so you have to effect all of the sprites separately. The only way I know to do that is by using the family of sprites but that affects EVERY instance on the screen and not just the one that has been hit. I understand families and use them all of the time but I'm just trying to figure out how to distinguish between separate instances of the same family of sprites. I'm not sure if it is possible in this case. @lucid - do you have any ideas about this?
Image
B
20
S
4
Posts: 382
Reputation: 3,004

Post » Wed May 21, 2014 6:43 pm

Try adding a variable to the Spriter object that uses 0 for no collision and 1 for collision. Then have the child objects of the Sprite object check that variable. This should solve your problem, though I think you're doing something else wrong, otherwise you wouldn't have to do that (I don't in a similar situation). It's hard to be sure without seeing the code, though.
B
89
S
47
G
25
Posts: 535
Reputation: 21,827

Post » Thu May 22, 2014 4:26 pm

Here's the code I'm using:
Image

Here's the result:
Image

As you can see, the result is that all of the zombies light up, even the ones that aren't being hit. Since the runner family of objects contains all of the sprites used in every runner, I don't know how to affect the family without affecting all of them. Thanks.
Image
B
20
S
4
Posts: 382
Reputation: 3,004

Post » Thu May 22, 2014 7:29 pm

I am on my phone so sorry I can't give you a more thorough example but...

What you want is to call a function with the family UID as the parameter when a collision is detected.
So it should look something like...

Condition
PsyAttacks on collision with ZombieFamily ---> Call function "zombieEffects"(ZombieFamily.UID)

And then create that function

On Function "zombieEffects"
ZombieFamily pick by UID (function.param(0)) ---> do fancy effects


Hope this helps :)
B
12
S
2
G
1
Posts: 26
Reputation: 835


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 13 guests