1_physicseditor

Guest Post: How to Use PhysicsEditor Colliders with V-Play

By Christian

Since the last guest post from Niklas Hösl, one of the creators of the ski jumping game HighJump 2014, we have received many requests asking how they imported the physics shapes into their game. So read on and download Niklas’ tool to add any physics polygons to your V-Play game.

As you know from my last post, we needed to create quite complex colliders for our hill elements at HighJump 2014. To accomplish this we used the great Qt-based tool PhysicsEditor, from the same author as TexturePacker. The problem was that PhysicsEditor does not support V-Play by default yet, meaning that you can’t generate output that can be directly used in your V-Play game.

One possibility to solve this problem was to convert the output from another engine to V-Play by hand. But this would have been very time consuming and error prone…

This was the reason why I created a small tool in C# using the Newtonsoft Json.NET Library, which lets you convert the output of the PhysicsEditor to a V-Play PolygonCollider. Read on for a step-by-step guide how to do that.

Step 1 – Download the Converter Tool

First of all download my converter tool and unzip the download archive. If you haven’t done so, install PhysicsEditor now and import your sprites to make polygon shapes out of them.

Step 2 – Export to JSON

Next, select the Lime + Corona (JSON) exporter format on the right side of the window (highlighted yellow in the screenshot below).

Now select “Publish” or “Publish As” and store the file in the same directory as the unzipped JSONtoVPlayCollider.exe.

1_physicseditor

Step 3 – Create the qt_input.txt file

Then open the qt_input.txt file, which is in the same directory. It consists of an example line that gives you the structure of the input:

[full_filename] [width in pixels] [height in pixels] [optional: “s” for static body type]

2_converter_files

The first part is the file name that you just published via PhysicsEditor followed by the width and the height of the image file, you used in PhysicsEditor. Finally, you can optionally define if the collider(s) should have the body type static by adding an s to the end of a line.

The tool can convert multiple files at once. Just add another line in the same format as the first one.

Step 4 – Run the Converter Tool

Save the file and start the JSONtoVPlayCollider.exe. If you started the tool via the CLI you will see a success output like shown in the following image.

3_running

Step 5 – Importing PhysicsEditor Polygons in V-Play

If the tool says “Done!” open the qt_ouput.json file, which holds the converted PolygonCollider information and looks like this:

4_output

Copy the PolygonColliders to your V-Play qml file in QtCreator and you are ready to go. The exported qt_output.json file contains all colliders of the input separated by the name of the input file.

 

Now creating complex colliders should be no big deal anymore. I hope this will help you to save time and create even cooler games!

 

PS: I appreciate any feedback to the tool – just add your comments below.

3 Responses

  1. Maxim Nawangwe March 20, 2014                    

    This is a great addition. is there any way the converter can be run on mac?

  2. Niklas March 20, 2014                    

    I will port the tool to Java in the next days, so you can use it on your Mac and also on Linux.

  3. AndreasLoew March 27, 2014                    

    There’s no need to use a converter.

    PhysicsEditor allows you to create your own output format.

    See

    http://www.codeandweb.com/blog/2012/05/30/customize_physicseditor_exporter

Leave a Reply

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support