Allowing Families in Families

0 favourites
  • 8 posts
  • 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

  • Since objects aren't restricted to just 1 family. you can have your "regular" families, and your "on top" family as well.

  • Yes, the way families work in Construct 2 allows you to simulate multiple-inheritence simply by adding multiple families.

  • 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.

  • 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.

  • 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

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

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