collide with any kind of enemy

Get help using Construct 2

Post » Mon Mar 25, 2013 12:54 pm

If I have 10 different kinds of enemies and 10 different kinds of bullets, is there any way to have a check to see if a bullet collides with any enemy?   Or for every enemy (among different kinds) just see if it collides with whatever bullet and take the dammage that bullet packs with it in one of it's object variables?

I'm trying to figure out a way to do this without having 10 collision checks for each bullet type or 10 different collision checks with each enemy type.

In a traditional language you'd just have a generic "object" class with health and collision checks and have subtypes inherit from that... I guess I'm trying to encapsulate collisions.
Follow my CZero development on twitter https://twitter.com/CaptainZeroGame
B
39
S
10
G
4
Posts: 149
Reputation: 6,611

Post » Mon Mar 25, 2013 1:15 pm

You can use families for that, or alternatively put all bullets in single object and all enemies in single object.
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Mon Mar 25, 2013 2:09 pm

That's right... Families... I remember now thanks!
Follow my CZero development on twitter https://twitter.com/CaptainZeroGame
B
39
S
10
G
4
Posts: 149
Reputation: 6,611

Post » Mon Mar 25, 2013 2:30 pm

I recomend single Objects for the performance, but this would need some rework
B
15
S
6
G
6
Posts: 512
Reputation: 5,550

Post » Mon Mar 25, 2013 4:20 pm

Yes Families are awesome, I just figured out how to do that too.

For enemies you can have families and for bullets too, but for the bullet have something like a "Type" variable so that you know what kind of bullet family hits what kind of enemy family.
B
26
S
5
G
5
Posts: 98
Reputation: 4,734

Post » Fri May 17, 2013 6:57 pm

It's object inheritence. Well played, Construct 2!
Follow my CZero development on twitter https://twitter.com/CaptainZeroGame
B
39
S
10
G
4
Posts: 149
Reputation: 6,611


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 23 guests