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