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
95
S
33
G
128
Posts: 5,491
Reputation: 81,570

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
95
S
33
G
128
Posts: 5,491
Reputation: 81,570

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
18
S
5
Posts: 149
Reputation: 1,626

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.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
127
Posts: 1,762
Reputation: 67,845

Post » Sat Nov 18, 2017 12:42 pm

@dop2000

Thanks, will check it out.
B
18
S
5
Posts: 149
Reputation: 1,626


Return to How do I....?

Who is online

Users browsing this forum: Flipop and 19 guests