How do I Destroy Irregular Shapes

Get help using Construct 2

Post » Mon Oct 19, 2015 3:02 am

Hi Everyone,

I have working right now a tile being destroyed when something collides with it but with rand you can only have rectangles. I want an irregular collision shape to destroy tiles that it touches. Is this even a possibility?

Image

Talk soon.
B
39
S
11
G
3
Posts: 279
Reputation: 8,446

Post » Mon Oct 19, 2015 5:24 am

The first capx attached here should help:
how-do-i-know-which-tile-is-being-hit-on-collision_p877612?#p877612

It highlights all the tiles that overlap the tiles, but you could then take that and clear those tiles.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Mon Oct 19, 2015 6:24 am

wow thanks for the super quick reply R0j0Hound! you are always a great help. :)
B
39
S
11
G
3
Posts: 279
Reputation: 8,446

Post » Mon Oct 19, 2015 7:17 am

I tried substituting create object with erase and it doesnt work as i imagined it would. does erase work differently?
B
39
S
11
G
3
Posts: 279
Reputation: 8,446

Post » Mon Oct 19, 2015 5:50 pm

Event #2 creates all the Sprites in a rectangle and event #3 removes the sprites not overlapping. So to actually make it delete tiles you need a new event below all that:

Mouse button is down
for each tile
--- tilemap: erase tile at (self.positionToTileX(tile.x), self.positionToTileY(tile.y))

To make it only happen when you need it, put all the events in a group and disable/enable it as needed.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Tue Oct 20, 2015 5:56 am

Thanks again for the help with this R0J0hound!
This is what I got if I understand you correctly. It doesn't function just yet. In my game I have a little bomb that I want to erase terrain when its overlapping. I am going to keep fiddling with it and see if I can make it work. :)

CAPX_DestroyIrregularShapes
B
39
S
11
G
3
Posts: 279
Reputation: 8,446

Post » Tue Oct 20, 2015 6:09 am

I am embaressed to say i also don't understand why when comparing the tile index we check the value not equal to -1. I think maybe my errors are in my understanding.
B
39
S
11
G
3
Posts: 279
Reputation: 8,446

Post » Tue Oct 20, 2015 7:23 pm

"-1" just means there is no tile there. Your capx referenced tilemap instead of tile in the event which is a simple mistake. Anyways here's a working example. Instead of creating a bunch of tile sprites it just moves around one to do the detection. The advantage is it eliminated a few events.

https://dl.dropboxusercontent.com/u/542 ... pping.capx
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Wed Oct 21, 2015 1:19 am

most excellent. Thank you R0j0hound for all your help. I cannot wait to test when I get home. :)
B
39
S
11
G
3
Posts: 279
Reputation: 8,446

Post » Wed Oct 21, 2015 4:31 am

this method works perfectly. I my personal game script I have it on animation playing erase tile. Very good and thanks again.
B
39
S
11
G
3
Posts: 279
Reputation: 8,446

Next

Return to How do I....?

Who is online

Users browsing this forum: David181, evillair and 51 guests