Colision question

Get help using Construct 2

Post » Sun Jul 15, 2012 4:58 pm

Is there a way to check if an object is in its entirety inside another object?
Or to check if every single pixel of one object is colliding with another object?
B
33
S
12
G
7
Posts: 227
Reputation: 7,582

Post » Sun Jul 15, 2012 10:23 pm

It can be calculated easily with a bit of math if the objects are boxes or circles. Also with a bit of logic you can use collision polygons.
http://dl.dropbox.com/u/5426011/examples12/sprite_in_sprite.capx

Making it work with rotated objects would complicate things a bit. It's doable but I would opt for objects with no rotation.

Finally it is possible to do a per-pixel check with the canvas plugin but I imagine it would be dog slow.
B
94
S
33
G
114
Posts: 5,362
Reputation: 73,785

Post » Sun Jul 15, 2012 11:11 pm

The user can actually change the angle of the object on a per 10 basis, and select from several differently shaped objects.

So the only solution would be to have up to 36 different mathematical expressions per shape, right? I think I'll try a different approach for my problem. :P

And I don't even want to it try with the canvas plugin, it won't end well.


Thanks for the reply.
B
33
S
12
G
7
Posts: 227
Reputation: 7,582

Post » Mon Jul 16, 2012 1:08 am

[quote]So the only solution would be to have up to 36 different mathematical expressions per shape, right?[/quote]
I avoid such situations when I can.

Here is a further refinement of the "poly" method that handles rotation.
http://dl.dropbox.com/u/5426011/examples12/sprite_in_sprite2.capx
B
94
S
33
G
114
Posts: 5,362
Reputation: 73,785

Post » Tue Jul 17, 2012 2:31 am

Thanks, I'll try to make the best use of it.
B
33
S
12
G
7
Posts: 227
Reputation: 7,582

Post » Sat Nov 18, 2017 11:48 am

@R0J0hound Can you update the links please. I want to see the formulas. I can use collision polygons to detect overlapping, but I'm wondering if it'll be faster to just use formulas instead of using sprites and checking collision polygons.
B
17
S
4
Posts: 143
Reputation: 1,489

Post » Sat Nov 18, 2017 12:03 pm

@Pandy
Check this post, it may be relevant.
I posted a few examples there where I perform hundreds of overlapping checks per tick and the impact on performance is quite small. According to Ashley, overlapping checks in C2 are well optimized.
Check out my awesome game Doptrix
B
17
S
9
G
53
Posts: 864
Reputation: 29,537

Post » Sat Nov 18, 2017 12:42 pm

@dop2000

Thanks, will check it out.
B
17
S
4
Posts: 143
Reputation: 1,489


Return to How do I....?

Who is online

Users browsing this forum: jezjones24 and 12 guests