In my previous post I introduced TexturePacker to handle a lot of images in a simple way to improve i.e. game performance, the developer of TexturePacker created another program called PhysicsEditor. With PhysicsEditor you can easily trace your display objects so when the object bounce with other objects in your game it looks like the object has the real shape and not some bounding box around it. Often images have a transparent background which determines the real “image”, but when two display objects collide we want to images to collide as there shapes and not a collision of the larger transparent backgrounds. Well, this can be solved with the tracing tool of PhysicsEditor. Besides the tracing, another great thing about PhysicsEditor is that you can set your properties of each individual display object.
In case you’re new to PhysicsEditor, you can download the program here: http://www.codeandweb.com/physicseditor
I’m still in Koh Lipe, we did some great snorkeling and really enjoyed walking around the island. If you ever visit Thailand I would recommend to visit Koh Lipe. Just not as many tourists like in some of the other Thai Islands and the water is just stunning. We are pretty much relaxing on a paradise island. I’m now already 1.5 month traveling and I already got my first itches to start working again and missing “normal” life. But I guess this is part of a trip like this, that at some point you have enough of traveling and rather go home. So being on a beach and away from some of the loudness and chaotic street life of Asia provided me with some extra time to work on my Rolly Bear World Project. I have mostly been reading in the last couple of days. I downloaded the book Corona SDK Mobile Game Development: Beginner’s Guide from Michelle M. Fernandez to read more about Corona SDK. I hope this will give me some more resources to move the Rolly Bear World project forward :)
In this post I show you how you can use PhysicsEditor. I’m using my next post to show how to load everything and start using it (the important part!). So this post is just about using the program PhysicsEditor. Which actually is not much of a big deal.
Step 1: Load your art work/ sprites into PhysicsEditor and start the trace tool
Click in the menu bar on “add sprites” to open your local directory and select the sprites/ art work you want. All your artwork should appear in the left container. Select one of them and click on the trace tool.
Step 2: Create the best possible trace of your display object
When you click the trace tool, a new dialog windows shows the object and with red lines how PhysicsEditor suggests the trace. With tolerance you can optimize the trace or use any of the other options provided by PhysicsEditor. When you’re satisfied click on ok and continue with the next display object. Note that the best possible trace means that the red lines follow most precisely the shape of our object. Depending for what the object is used for you care or care less about the precision of the trace.
Step 3: Select Corona as Exporter method
As we are building a game with Corona SDK, make sure you select Corona as export method in the right container. It could not be more easier :)
Step 4: Set Physics Parameters
You can set different physics parameters via PhysicsEditor. These are often the physics parameters you would add in your “physics.addbody” line of code. Now you can easily add them here via PhysicsEditor and come back to change them if you want anytime. For Rolly Bear, at this stage, I just used some random figures, but I will likely update them later on when I did some testing on my levels. For now it’s just getting PhysicsEditor up and running and use the program.
Now use “Publish As” to publish a .lua file in your game project folder. I called it platformshapes.lua as it is the .lua file describing the tracing or shapes of each platform object. Make sure this file is part of your game project folder. In the next tutorial I will show you how to use it.
Also make sure you save your PhysicsEditor file via the “Save” button, this will create a .PES file and this is very handy when you want to add/ delete or change any of the physics paramters later on when you did some testing on your game.
This is all for now, the latest GitHub repository can be found here.