WCK and edge shapes

Hi guys

I've been using WCK for a while and have most things worked out (love the library by the way!).

Now, I've been trying to build a tile based platformer. I've run into some issues, which are apparently very common (the character snags where the tiles join if the character is square OR the character does little jumps, when going over where two tiles join, if he is circular).

After doing some research, I found that the only solution to this is edge shapes.

The way I use WCK, is that I set-up all my objects on stage and code on the timeline, referring to the objects by instance names.

Is there are way for me to use edge shapes with the current setup?

Do edge shapes allow me to destroy a particular tile, the edge shape is made out of?

Thank you in advance for you help!

Tom
So I'm guessing you have each tile define it's own box? Yeah, that's not going to work well. Things will always get snagged on the corner of each box.

WCK has edge shapes (see the demos) but you don't really need them to solve this.

What I would do is not have your tiles linked explicitly to Box2D shapes.

For example, lets say you lay out a row of 5 tiles. They are just graphics though, not Box2D entities. Then take an extra step and lay down a separate object that DOES define the Box2D Box, and stretch that so it extends the length of all 5 tiles. This new symbol could be something that just makes itself invisible in its first frame or something.

For my game I built up a bunch of symbols named like WoodBox2x4, WoodBox5x6, WoodBox1x1, etc. where the 2x4 represents how many "tiles" they contain. Then it defines one Box2D box to cover all those tiles together.
mayobutter's solution will work fine if your level's don't change but you may need to set up a lot of platforms depending on the largest horizontal number of tiles used.

My approach in a recent game was a little bit of a workaround. On my level I have some "place holder" platforms that I look for and remove when the level is initialized. I get the coordinates, size and then create my custom platforms that will set up a new box2d body and the graphics.

This way, I don't have to add extra platforms if I need something wider than what I have.
Hi Guys

Thank you very much for the replies! Both of the solutions make perfect sense to me, however here is the problem I have ...

Let's say I have a row of six (32x32) tiles and I want my character to drop a bomb in the middle to destroy one of them.

If you need a reference, have a look at my game Maxploder - http://ninjadoodle.com/maxploder/ (I made this using a different engine, which sadly gave me a lot of issues).

I'm not actually sure if there is a solution for what I need 🙁

If you have some ideas that would be awesome ...

Thanks again for your help!
I think it's possible to do what you want with either methods. You have to determine which visual "tile" you want to remove from the row and then create two new "platforms".

Say, you have 6 tiles and you want to remove the fourth.
XXXXXX (1 row of 6 tiles)
becomes:
XXX_XX (1 row of 3 and 1 row of 2 tiles)

With either method, you'll have to remove the old platform and create the new ones manually. Unless, I'm missing something.

I know you mentioned that circular characters jump at rectangular shape contacts but have you tried both big and little circles as a character?
After some extensive research on Maxploder... (there should be a rule against posting links that might make people inadvertently spend hours doing something else 😀)

You might find this post interesting: viewtopic.php?f=8&t=7917
You could probably use a variation on that idea to handle more general cases. For example say your tile is as on the left here, then you would have a generic 'joiner' piece as on the right:
Attachment:
tiles1.png
tiles1.png [ 1.62 KiB | Viewed 292 times ]

Everywhere that a tile has a neighbor, it would have a joiner fixture in that direction. The picture is not very clear but hopefully it makes sense (there are four joiners here):
Attachment:
tiles2.png
tiles2.png [ 3.64 KiB | Viewed 292 times ]


It might not give you as snag-free a result as the other methods mentioned here, but it seemed to work ok for the guy in that thread and it might be worth a try as I'm sure it would be easier to fit into your existing tile engine. When a bomb removes a tile, you would just need to update the joiners for the neighbors of the removed tiles. It would give you a lot of fixtures, but since they are all static they should not cause too much processing time increase. You only really need the joiners in places where two tiles share a straight edge anyway.
Hi Guys

Once again, I want to say thank you for your help!

You have given me some ideas for possible workarounds which I haven't thought of before.

I wish there was an easier way of doing this, but it looks like this will have to do ...

For a game like Maxploder, I think I can use these workarounds in one way or another as there are only a few destroyable tiles.

However, if I was to make something like Boulderdash or a 2d version of Minecraft where most tiles in the world can be destroyed, these techniques might be a little difficult to maintain, as there would be a lot of extra tiles or fixtures, or too many shape possibilities (lets say you want to explode your way through a 10x10 block of tiles).

I noticed that ( and I could be wrong, but it seems to work ) the snagging does not happen with 'extras.Platform' .... hmmm I wonder why?

Thank you again, I really appreciate you help!
That bevel idea by irresistible force seems interesting. I tried to do apply it to the player but it still kept bouncing.

Original thread: https://box2d.org/forum/viewtopic.php?t=8706