How do I add or remove sprites from a Family during runtime?

Get help using Construct 2

Post » Sat Dec 31, 2016 9:09 pm

I have multiple families set up.

I have my sprites part of multiple families, but I'm wondering if it's possible to add or remove the sprite from a family during run time.

I've been looking all over the forums and the site, and I check the FAQ page and didn't find anything on it.

Is it possible to change families during play?

For an example, each of my families has specific functions. Named, AstarMovement etc...

I might want to spawn a named tree that moves. So to do this, the tree must belong to both named and AstarMovement families. But if I want to change a tree that was just spawned with just Named to be able to move, I have to delete the first tree and replace it with one that's in both families. (I hope I'm explaining this right...)

Is it possible to add or remove sprites from a family during play/runtime?
B
7
S
2
Posts: 39
Reputation: 953

Post » Sat Dec 31, 2016 10:56 pm

Families are an abstraction. You can't remove the 'familiness' at run time, but you can disable the behaviours, generally.
ImageImageImage
B
71
S
21
G
221
Posts: 3,649
Reputation: 124,227

Post » Sat Dec 31, 2016 11:20 pm

I'm assigning behaviors via families.

So, in order to disable a behavior, I'd have to put each sprite into every single family that I have, and then disable the behavior I don't want. Based on the scenario.

I'm trying to prevent Sprites with 500 behaviors, and instead have a sprite with 20 Families of behaviors.

This way I could add or remove complex behaviors to any sprite, regardless of it's current set.

I'm trying to do Entity Component stuff, but it's hard to figure out how to do it in Construct 2.

Doing it the other way around would mean that I'd have to make one sprite with EVERY behavior and disable them all at start up, and then turn them on conditionally. I think that would be a mess.
B
7
S
2
Posts: 39
Reputation: 953

Post » Sat Dec 31, 2016 11:41 pm

C2 can't do that.
ImageImageImage
B
71
S
21
G
221
Posts: 3,649
Reputation: 124,227


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 14 guests