Allowing Families in Families

Discussion and feedback on Construct 2

Post » Wed May 28, 2014 3:52 am

Hi,

To simulate class hierarchies and also multiple classification, it would be very helpful to support families in families. The "algorthim" for instance detection would only need to be extended to work recursively to find all "picks" in the family and includes other families. This would allow creating very general event code.

For example,

I have some code that ensures that whatever is dragged on a screen is put on the top layer. With families in families I could write this event code using one on-top family, in an include layout and include it in all layouts and then just the object types or already existing families of object types into the on-top family. Like this the right instances would be identified automatically.

Dan
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Wed May 28, 2014 8:20 pm

Since objects aren't restricted to just 1 family. you can have your "regular" families, and your "on top" family as well.
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Wed May 28, 2014 9:12 pm

Yes, the way families work in Construct 2 allows you to simulate multiple-inheritence simply by adding multiple families.
Scirra Founder
B
398
S
236
G
88
Posts: 24,433
Reputation: 194,635

Post » Wed May 28, 2014 11:49 pm

I can see how inheritence between families could be good. For example, you have a base "Character" class, with a few behaviors and instance variables of it's own. And then, you have different kinds of character families, like "Enemies", "NPCs" and "Players", who could Inherit those properties and events. Every character could have an "HP" variable, from the Character, but you could create specific events (like, Player hits Enemy) that could influence this property.

Not something that kills the engine, and there are some workarounds around that, but it could be easier to do a few things this way.

Any way, the way Construct 2 does multiple inheritance IS a lot more convenient for games on most cases than the single-inheritance with multiple levels would be, for sure.
B
20
S
5
G
1
Posts: 37
Reputation: 1,139

Post » Thu May 29, 2014 12:26 pm

@Sargas,

I of course again agree with you. And I am again looking at efficiency and self-documentation. Its better to allow families in families, than requiring the developer to readd all object types in a second family. Because, its easier to do, therefore less error prone, and its also more self explanatory, looking at the family in families.
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Tue Jun 24, 2014 12:28 pm

Though this post is about one month old, I agree it would be nice to have some Inheritance instead of creating multiple families.

Right now, it forces you to create multiple families and it can be quite difficult to maintain properly. Sometimes you realise, it would have been better to put your objects in one family instead of another and it can be quite painful to move things around depending on how many events you got.

Anyway it's not a biggie but it would be nice to have :)
B
12
S
2
Posts: 85
Reputation: 899

Post » Tue Jun 24, 2014 3:04 pm

The painful lesson for most. Just work with families. I know this pain oh so well. There are times you don't need to. but overall it's just a good idea.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,028

Post » Wed Jun 25, 2014 4:12 pm

Indeed. Working with families allow creating a level of "indirection" - i.e. avoiding the "hard coding" of object types in event and action code. Like this object types can be exchanged, without needing to change any code
B
8
S
4
G
1
Posts: 205
Reputation: 1,354


Return to Construct 2 General

Who is online

Users browsing this forum: dand and 18 guests