[suggesstion] Family Inheritance

Discussion and feedback on Construct 2

Post » Fri Nov 08, 2013 4:21 am

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?jeeba2013-11-08 04:24:13
B
10
S
2
G
1
Posts: 48
Reputation: 1,265

Post » Fri Nov 08, 2013 4:34 am

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.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,028

Post » Fri Nov 08, 2013 6:38 am

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
B
10
S
2
G
1
Posts: 48
Reputation: 1,265

Post » Fri Nov 08, 2013 6:49 am

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.
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Fri Nov 08, 2013 7:01 am

oh well, that solution of a family variable is my current method of work. Well thanks Mad for the input :)
B
10
S
2
G
1
Posts: 48
Reputation: 1,265

Post » Fri Nov 08, 2013 11:05 am

You always can take the boss by its IID, instance variable, or health status, sorting and picking the higher health, or something else.
Image
B
108
S
24
G
18
Posts: 1,372
Reputation: 22,817

Post » Fri Nov 08, 2013 5:21 pm

[code]+Enemy.Health = 0
+Boss.UID = Enemy.UID
-> Boss.Speed = 100[/code]
Should work. Works for my game.TL222013-11-08 17:21:33
B
94
S
34
G
8
Posts: 314
Reputation: 11,199

Post » Sun Nov 10, 2013 11:45 am

This will work for me, but I was wondering, maybe we need a family type condition like:
+family is "Boss"
B
10
S
2
G
1
Posts: 48
Reputation: 1,265


Return to Construct 2 General

Who is online

Users browsing this forum: AnD4D and 13 guests