How do I make Collision Area

Get help using Construct 2

Post » Thu May 15, 2014 4:19 am

Is there any way to make this image a Collision Area without doing it manually? PNG image with transparency. The player must be inside the Collision Area
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 8
Reputation: 193

Post » Thu May 15, 2014 4:34 am

You could quickly recreate that image with a tilemap and give it the solid behavior. Only the filled tiles will trigger a collision. This would probably be the fastest and easiest way to accomplish what you want, plus it is really easy to change later.
B
39
S
12
G
11
Posts: 331
Reputation: 7,727

Post » Thu May 15, 2014 4:41 am

Any sprite (image you add by default has collision enabled. You can define the actual collision area or outline by setting the collision polygon properties. C doe attempt to do this automatically by generally needs modification for accuracy and for performance. More than 8 points can degrade performance if you have a lot of objects that have collisions enabled.
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Thu May 15, 2014 3:44 pm

@TheDom
That works well if the player is outside the lines. In the case mentioned above, the OP said the player had to be inside. This means the collision polygon created by the image is the opposite of the collision polygon needed. The player is inside the lines while the area outside the lines represent the collision polygon. Also, as you mentioned, more than 8 points degrades the performance, so your suggestion would not be optimal anyway. The image above would require 18 points to create.

@alexheg
You will get good performance and results if you use my suggestion above.

I hope this helps you get what you need and good luck with your project.
B
39
S
12
G
11
Posts: 331
Reputation: 7,727

Post » Thu May 15, 2014 6:05 pm

I see what you mean. Here's a solution too. For each straight line segment of the image, create an invisible sprite and draw(stretch) them along each line acting as invisible walls. The will be rectangular and only have 4 points. You can create image points if you need to and pin each one in position but, I don't think it will be necessary, you'll have to decide about that based on your specifics in the game. The just set the collisions property to disabled for the main image. Put all of the walls into Family for easy coding On Collision events. Then it works whether the player collides from inside or out.

Might be a little easier too.
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283


Return to How do I....?

Who is online

Users browsing this forum: Jackriduk, kiki4construct, osek95 and 19 guests