New feature in familys

Discussion and feedback on Construct 2

Post » Fri Oct 18, 2013 9:41 am

Dear Scirra Team

First of all, I love Construct 2 and almost all of your weekly updates.

I noticed a small thing, that isn't necessary but would be great in some of the new releases.

I'm talking about an option to easy detect which kind of object of a family is acutally taken (e.g. in a foreach-loop)

Here's an example picture i made (I'm really sorry about the bad quality of this picture and the fact I had to edit it (with Paint ) instead of making a printscreen in Construct 2 but thats my only option at the moment...)
https://www.dropbox.com/s/bv6v459bt6ci6hv/lulz.png

Maybe you think this change would be useless (and maybe you're right in this example picture) but imagine:
You detect a collision between a shot and the Enemy Family and each of the containing objects (EnemyBig, EnemyExplode) have different ways to deal with it.
E.g. EnemyBig gets smaller, EnemyExplode shoots bomb fragments in each direction etc.

Imagine Shot is a family too and just some kind of shots would hurt specific kind of enemys.

I know there are some workarounds for this problem, but I think it would make things easier.


And here a small code example of what I mean (ActionScript 3.0)

foreach(Enemys)
{
var EnemyBig:Enemys = Enemys as EnemyBig;
var EnemyExplode:Enemys = Enemys as EnemyExplode;

if(EnemyBig != null) { Enemys.Health = 3; }
if(EnemyExplode != null) { Enemys.Damage = 2; }

}


I hope you unterstand what I mean and you will implement it in a future release.


Thanks,

Geru Geru2013-10-19 09:33:21
B
20
S
3
G
2
Posts: 34
Reputation: 2,675

Post » Fri Oct 18, 2013 12:55 pm

You can already do this with instance variables. Just make a text instance variable which is the same as the name of the object.
Scirra Founder
B
387
S
230
G
87
Posts: 24,245
Reputation: 192,210

Post » Fri Oct 18, 2013 2:28 pm

Haha Ashley you're right...

Just stupid that I never thought about that easy solution

Thanks for your help
B
20
S
3
G
2
Posts: 34
Reputation: 2,675

Post » Fri Oct 18, 2013 4:28 pm

You can it like this as well:
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,620

Post » Fri Oct 18, 2013 7:36 pm

[QUOTE=ramones] You can it like this as well:
[/QUOTE]
Super useful post - could this thread be moved to "How do I..."?
B
44
S
9
G
2
Posts: 141
Reputation: 4,172


Return to Construct 2 General

Who is online

Users browsing this forum: dwtiger, tarek2, Yahoo [Bot] and 1 guest