physicsSource property

Hi dyson,

Do you a sample project which uses the physicsSource property I should look at?  Or any more doco re how to use this feature.   It seems very interesting.  Some specific questions:

Q1 - Could I use PhysicsEditor to create boundaries and then with physicsSource there is a way to automatically associate the shape with the tile such that in MTE when you create a physics object based on this tile it will have this physics area?   

Q2 - Is the idea you finalise your actual Tileset image (e.g. PNG image with many different tiles on it) and then use Physics Editor to define a whole lot of shapes on this?   Or is it one PhysicsEditor file per tile?

Q3 - Does it support the concept of the tileset image has had “extrusion” of 1 pixcel applied to it (e.g. via texture packer)

Q4 - Any my question re is there a working example that shows hows this works.

Hello greg,

The Platformer - Angled sample project map named AngledPhysics4.tmx uses physicsSource and assets created using PhysicsEditor. Just comment out all but the map you want to load in main.lua of the sample to try it out. I believe the relevant line is 21. 

  1. In Tiled you’ll have to assign the shape to the tile using a tile property named shapeID. For example in PhysicsEditor I named the cross shape “cross”, so in Tiled I gave the cross tile a shapeID = cross. When you launch your map with physics enabled the engine will automatically retrieve the shape data and configure the physics object based on what you set in PhysicsEditor.

  2. First you load the individual tiles into PhysicsEditor as seperate images. After producing your output you assemble the tiles into a tileset using TexturePacker. Then in Tiled you assign the shapes you created to your tiles.

  3. In this case you’ll want to create your physics shapes BEFORE extruding the tiles. You can take care of extrusion when you finish making the shapes and put all the tiles together.

The example in Platformer - Angled shows two ways to go about it. The red shape tileset has a tileset property containing the shape data file, and each tile has the shapeID property pointing to a shape in that data set. The blue shape tileset’s star-shaped tile has both the shape file and the shapeID in tile properties; the other blue shapes will not auto generate physics bodies.

wow - this is very impressive Dyson!

Hello greg,

The Platformer - Angled sample project map named AngledPhysics4.tmx uses physicsSource and assets created using PhysicsEditor. Just comment out all but the map you want to load in main.lua of the sample to try it out. I believe the relevant line is 21. 

  1. In Tiled you’ll have to assign the shape to the tile using a tile property named shapeID. For example in PhysicsEditor I named the cross shape “cross”, so in Tiled I gave the cross tile a shapeID = cross. When you launch your map with physics enabled the engine will automatically retrieve the shape data and configure the physics object based on what you set in PhysicsEditor.

  2. First you load the individual tiles into PhysicsEditor as seperate images. After producing your output you assemble the tiles into a tileset using TexturePacker. Then in Tiled you assign the shapes you created to your tiles.

  3. In this case you’ll want to create your physics shapes BEFORE extruding the tiles. You can take care of extrusion when you finish making the shapes and put all the tiles together.

The example in Platformer - Angled shows two ways to go about it. The red shape tileset has a tileset property containing the shape data file, and each tile has the shapeID property pointing to a shape in that data set. The blue shape tileset’s star-shaped tile has both the shape file and the shapeID in tile properties; the other blue shapes will not auto generate physics bodies.

wow - this is very impressive Dyson!