[suggesstion] Family Inheritance

0 favourites
  • 8 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Lets suppose I have two types of units, minions and bosses, they each have an instance variable called health. If I wanted to lower their health when a proyectile impact it, I have to create 2 events, one for the minion family and one for the boss family. But If I could have inheritance, then I could create a unit family that have the health variable and make minion and bosses their child.

    ?What do you think about it?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What you need already is implemented.

    Just make 1 Family called Enemy. Give that Family health. All Enemies are part of the Enemy Familiy.

    Then use 2 other Families called Bosses and Minions.

  • It will not really work, if only Bosses got the speed variable, then you cannot capture events of enemy health, you have to give boss a health variable and then capture the events on boss.health

    Let me give it on pseudocode

    enemy.health = 0 -> boss.speed=100   

    This will make all bosses speed to 100, not the one with health = 0

  • Yeah it'd be nice but Ashley already said this probably won't happen. In a case like this I'd put enemies & bosses in the same family and have a family variable to differentiate them.

  • <img src="smileys/smiley19.gif" border="0" align="middle" /> oh well, that solution of a family variable is my current method of work. Well thanks Mad for the input :)

  • You always can take the boss by its IID, instance variable, or health status, sorting and picking the higher health, or something else.

  • +Enemy.Health = 0
    +Boss.UID = Enemy.UID
    -> Boss.Speed = 100

    Should work. Works for my game.

  • This will work for me, but I was wondering, maybe we need a family type condition like:

    +family is "Boss"

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