@XenonBL: Right.
I can simply fix this. But scaling the shapes might change the physics behavior. I corona’s case this is a bit of a problem so.
I changed the exporter. Please copy the following data to your
/Applications/PhysicsEditor/Contents/Resources/exporters/corona folder.
They add a scaling factor you can use when requiring the file.
It also add the IsSensor feature to single polygons.
I just fixed it in the text editor and had not yet time to test it.
Please give me feedback if that works for you.
corona.lua:
[lua]-- This file is for use with Corona Game Edition
– This file is automatically generated with PhysicsEdtior (http://www.physicseditor.de). Do not edit
– Usage example:
– local scaleFactor = 1.0
– local physicsData = (require “shapedefs”).physicsData(scaleFactor)
– local shape = display.newImage(“objectname.png”)
– physics.addBody( shape, physicsData:get(“objectname”) )
– copy unpack to local scope
local unpack = unpack
module(…)
function physicsData(s)
local physics = { data =
{ {% for body in bodies %}
{% if not forloop.first %}, {% endif %}
["{{body.name}}"] = {
{% for fixture in body.fixtures %}{% for polygon in fixture.polygons %}{% if not forloop.first %} ,{% endif %}
{
density = {{fixture.density}}, friction = {{fixture.friction}}, bounce = {{fixture.bounce}}, {% if fixture.isSensor %}isSensor=true, {% endif %}
filter = { categoryBits = {{fixture.filter_categoryBits}}, maskBits = {{fixture.filter_maskBits}} },
shape = { {% for point in polygon %} {% if not forloop.first %}, {% endif %} {{point.x*s}}, {{point.y*s}} {% endfor %} }
} {% endfor %} {% endfor %}
}
{% endfor %}
} }
function physics:get(name)
return unpack(self.data[name])
end
return physics;
end[/lua]
exporter.xml
\<exporter\>
\<name\>corona-box2d\</name\>
\<displayName\>Corona\</displayName\>
\<description\>Exporter for Corona TM SDK, lua\</description\>
\<version\>1.0\</version\>
\<yAxisDirection\>down\</yAxisDirection\>
\<physicsEngine\>box2d\</physicsEngine\>
\<template\>corona.lua\</template\>
\<fileExtension\>lua\</fileExtension\>
\<anchorPoint\>
\<enabled\>no\</enabled\>
\</anchorPoint\>
\<origin\>
\<type\>fixed\</type\>
\<relX\>0.5\</relX\>
\<relY\>0.5\</relY\>
\</origin\>
\<body\>
\</body\>
\<global\>
\</global\>
\<body\>
\</body\>
\<fixture\>
\<parameter\>
\<name\>density\</name\>
\<displayName\>Density\</displayName\>
\<type\>float\</type\>
\<min\>-1000\</min\>
\<max\>1000\</max\>
\<default\>2.0\</default\>
\</parameter\>
\<parameter\>
\<name\>bounce\</name\>
\<displayName\>Bounce\</displayName\>
\<type\>float\</type\>
\<min\>0\</min\>
\<max\>1000\</max\>
\<default\>0.0\</default\>
\</parameter\>
\<parameter\>
\<name\>friction\</name\>
\<displayName\>Friction\</displayName\>
\<type\>float\</type\>
\<min\>0\</min\>
\<max\>1000\</max\>
\<default\>0.0\</default\>
\</parameter\>
\<parameter\>
\<name\>isSensor\</name\>
\<displayName\>Is Sensor\</displayName\>
\<description\>If set the physial \</description\>
\<type\>bool\</type\>
\<default\>false\</default\>
\</parameter\>
\</fixture\>
\</exporter\>
[import]uid: 9611 topic_id: 6327 reply_id: 23150[/import]