{"id":467,"date":"2011-11-05T23:41:58","date_gmt":"2011-11-05T22:41:58","guid":{"rendered":"http:\/\/www.aymericlamboley.fr\/blog\/?p=467"},"modified":"2014-11-01T15:00:26","modified_gmt":"2014-11-01T14:00:26","slug":"physicseditor-template-for-the-citrus-engine","status":"publish","type":"post","link":"http:\/\/www.aymericlamboley.fr\/blog\/physicseditor-template-for-the-citrus-engine\/","title":{"rendered":"PhysicsEditor template for the Citrus Engine"},"content":{"rendered":"<p>Some months ago, I bought two softwares from <a href=\"http:\/\/www.code-and-web.de\/\" target=\"_blank\">code &#8216;n&#8217; web<\/a> : <a href=\"http:\/\/www.texturepacker.com\/\" target=\"_blank\">TexturePacker<\/a> to create SpriteSheet and <a href=\"http:\/\/www.physicseditor.de\/\" target=\"_blank\">PhysicsEditor<\/a> to create easily box2d object from png file.<\/p>\n<p>Today, I&#8217;m happy to share my first extension \/ template for PhysicsEditor&#8217;s software : I&#8217;ve created a template to export physics object for the <a href=\"http:\/\/citrusengine.com\/\" target=\"_blank\">Citrus Engine<\/a>.<br \/>\n<a href=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2011\/11\/PhysicsEditorObjects.swf\" target=\"_blank\"><br \/>\n<strong>This is a quick usage example<\/strong><\/a>.<br \/>\nClick on the physical object and press tab. The console is now open. Then write : <em>set Box2D visible false<\/em> and you will see its picture. It matches really well to the physical object!<\/p>\n<p><!--more--><\/p>\n<p>When I worked on <a href=\"http:\/\/www.aymericlamboley.fr\/blog\/kinessia-game-school-project\/\" target=\"_blank\">Kinessia<\/a>, I was sad that I couldn&#8217;t have physical object that I desired e.g. the catapulte which was a simple rectangle.<br \/>\nTo create complex box2d physical object you need to define vertices which are quite complex, and determine <a href=\"http:\/\/www.box2d.org\/manual.html\" target=\"_blank\">convex \/ concave polygons<\/a>. Actually PhysicsEditor do that. Thanks to its other templates (there is already a template for AS3 box2d but it is not based on the alchemy version), I have been able to create my template.<\/p>\n<p>It is really easy to use an object created from my PhysicsEditor&#8217;s template in your code. In your State class just do :<\/p>\n<pre lang=\"actionscript3\" line=\"1\">var pe:PhysicsEditorObjects = new PhysicsEditorObjects(\"Pe\", {x:200, peObject:\"muffin\", view:\"muffin.png\", registration:\"topLeft\"});\r\nadd(pe);<\/pre>\n<p>Be careful, the registration point is topLeft instead of center!<\/p>\n<p>To use my template, download the <a href=\"http:\/\/www.physicseditor.de\/\" target=\"_blank\">PhysicsEditor<\/a> and install it. You can use the free version. Then on Mac OS X right click on the application and go &#8220;inside&#8221;. Finally paste my <a href=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2011\/11\/citrusengine.zip\">template<\/a> in this folder : Contents\/Resources\/exporters. I think it isn&#8217;t too different on Windows.<\/p>\n<p>The software looks like this :<br \/>\n<a href=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2011\/11\/PhysicsEditor.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2011\/11\/PhysicsEditor-300x255.png\" alt=\"\" title=\"PhysicsEditor\" width=\"300\" height=\"255\" class=\"aligncenter size-medium wp-image-468\" srcset=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2011\/11\/PhysicsEditor-300x255.png 300w, http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2011\/11\/PhysicsEditor-1024x873.png 1024w, http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2011\/11\/PhysicsEditor.png 1153w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>This is my exporter.xml template file, you may want to add some options (take a look on the other templates) :<\/p>\n<pre lang=\"xml\" line=\"1\"><exporter>\r\n    \r\n    <!-- identifier of the exporter -->\r\n\t<name>box2d-alchemy<\/name>\r\n\t\r\n\t<!-- name for the dropbox -->\r\n    <displayName>CitrusEngine ActionScript (FLASH)<\/displayName>\r\n\t\r\n\t<!-- description of the exporter -->\r\n    <description>CitrusEngine ActionScript for Flash<\/description>\r\n\t\r\n\t<!-- exporter version -->\r\n\t<version>1.0<\/version>\r\n\t\r\n\t<!-- direction of the y axis: up \/ down -->\r\n    <yAxisDirection>down<\/yAxisDirection>\r\n\t\r\n\t<!-- physics engine to use: box2d, chipmunk -->\r\n\t<physicsEngine>box2d<\/physicsEngine>\r\n\t\r\n\t<!-- name of the template file -->\r\n    <template>citrusengine.as<\/template>\r\n\t\r\n\t<!-- file exension for the data file -->\r\n\t<fileExtension>as<\/fileExtension>\r\n\t\r\n\t<!-- anchor point settings -->\r\n\t<anchorPoint>\r\n\t    <!-- are anchor points supported ? yes\/no -->\r\n\t\t<enabled>no<\/enabled>\r\n\t\t\r\n\t\t<!-- relative position of the default anchor point -->\r\n\t\t<relX>0.0<\/relX>\t\t\r\n\t\t<relY>0.0<\/relY>\r\n\t<\/anchorPoint>\r\n\r\n    <origin>\r\n        <!--\r\n        origin (0\/0) point of the polygons \r\n        can be set to \"anchorPoint\" or \"fixed\"\r\n        Use \r\n\t\t<relX>0.5<\/relX>\t\t\r\n\t\t<relY>0.5<\/relY>\r\n\t\tto specify a fixed origin.\r\n\t\tDefault is 0.5\/0.5\r\n        -->\r\n        <type>fixed<\/type>\r\n\t\t<relX>0.0<\/relX>\t\t\r\n        <relY>1.0<\/relY>\r\n    <\/origin>\r\n\t\r\n\t<!-- custom global parameters -->\r\n\t<global>\r\n\t<\/global>\r\n\t\r\n\t<!-- custom body parameters -->\r\n\t<body>\r\n\t<\/body>\r\n\t\r\n\t<!-- custom fixture parameters -->\r\n\t<fixture>\r\n\t\t<parameter>\r\n\t\t\t<name>density<\/name>\r\n\t\t\t<displayName>Density<\/displayName>\r\n\t\t\t<description>Density of the shape. Used for calculating the mass.<\/description>\r\n\t\t\t<shortDescription>Density of the shape. Used for calculating the mass.<\/shortDescription>\r\n\t\t\t<type>float<\/type>\r\n\t\t\t<default>1<\/default>\r\n\t\t<\/parameter>\r\n\t\t<parameter>\r\n\t\t\t<name>friction<\/name>\r\n\t\t\t<description>Fricion.<\/description>\r\n\t\t\t<shortDescription>Friction.<\/shortDescription>\r\n\t\t\t<displayName>Friction<\/displayName>\r\n\t\t\t<type>float<\/type>\r\n\t\t\t<default>0.6<\/default>\r\n\t\t<\/parameter>\r\n\t\t<parameter>\r\n\t\t\t<name>restitution<\/name>\r\n\t\t\t<displayName>Restitution<\/displayName>\r\n\t\t\t<description>Restitution defines how much a shape bounces.<\/description>\r\n\t\t\t<shortDescription>Density of the shape. Used for calculating the mass.<\/shortDescription>\r\n\t\t\t<type>float<\/type>\r\n\t\t\t<default>0.3<\/default>\r\n\t\t<\/parameter>\r\n    <\/fixture>\r\n<\/exporter>\r\n<\/pre>\n<p>The ActionScript template :<\/p>\n<pre lang=\"actionscript3\" line=\"1\">package {\r\n\r\n    import Box2DAS.Collision.Shapes.b2PolygonShape;\r\n\timport Box2DAS.Common.V2;\r\n\r\n\timport com.citrusengine.objects.PhysicsObject;\r\n\r\n\t\/**\r\n\t * @author Aymeric\r\n\t * <p>This is a class created by the software http:\/\/www.physicseditor.de\/<\/p>\r\n\t * <p>Just select the CitrusEngine template, upload your png picture, set polygons and export.<\/p>\r\n\t * <p>Be careful, the registration point is topLeft !<\/p>\r\n\t * @param peObject : the name of the png file\r\n\t *\/\r\n    public class PhysicsEditorObjects extends PhysicsObject {\r\n\t\t\r\n\t\t[Inspectable(defaultValue=\"\")]\r\n\t\tpublic var peObject:String = \"\";\r\n\r\n\t\tprivate var _tab:Array;\r\n\r\n\t\tpublic function PhysicsEditorObjects(name:String, params:Object = null) {\r\n\r\n\t\t\tsuper(name, params);\r\n\t\t}\r\n\r\n\t\toverride public function destroy():void {\r\n\r\n\t\t\tsuper.destroy();\r\n\t\t}\r\n\r\n\t\toverride public function update(timeDelta:Number):void {\r\n\r\n\t\t\tsuper.update(timeDelta);\r\n\t\t}\r\n\r\n\t\toverride protected function defineFixture():void {\r\n\t\t\t\r\n\t\t\tsuper.defineFixture();\r\n\t\t\t\r\n\t\t\t_createVertices();\r\n\r\n\t\t\t_fixtureDef.density = _getDensity();\r\n\t\t\t_fixtureDef.friction = _getFriction();\r\n\t\t\t_fixtureDef.restitution = _getRestitution();\r\n\t\t\t\r\n\t\t\tfor (var i:uint = 0; i < _tab.length; ++i) {\r\n\t\t\t\tvar polygonShape:b2PolygonShape = new b2PolygonShape();\r\n\t\t\t\tpolygonShape.Set(_tab[i]);\r\n\t\t\t\t_fixtureDef.shape = polygonShape;\r\n\r\n\t\t\t\tbody.CreateFixture(_fixtureDef);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n        protected function _createVertices():void {\r\n\t\t\t\r\n\t\t\t_tab = [];\r\n\t\t\tvar vertices:Vector.<V2> = new Vector.<V2>();\r\n\r\n\t\t\tswitch (peObject) {\r\n\t\t\t\t{% for body in bodies %}\r\n\t\t\t\tcase \"{{body.name}}\":\r\n\t\t\t\t\t{% for fixture in body.fixtures %}{% for polygon in fixture.polygons %}\t\t\t\t\t\t\r\n\t\t\t        {% for point in polygon %}vertices.push(new V2({{point.x}}\/_box2D.scale, {{point.y}}\/_box2D.scale));\r\n\t\t\t\t\t{% endfor %}\r\n\t\t\t\t\t_tab.push(vertices);{% if not forloop.last %}\r\n\t\t\t\t\tvertices = new Vector.<V2>();{% endif %}\r\n\t\t\t\t\t{% endfor %}{% endfor %}\r\n\t\t\t\t\tbreak;\r\n\t\t\t{% endfor %}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tprotected function _getDensity():Number {\r\n\r\n\t\t\tswitch (peObject) {\r\n\t\t\t\t{% for body in bodies %}\r\n\t\t\t\tcase \"{{body.name}}\":\r\n\t\t\t\t\t{% for fixture in body.fixtures %}return {{fixture.density}};{% endfor %}\r\n\t\t\t\t\tbreak;\r\n\t\t\t{% endfor %}\r\n\t\t\t}\r\n\r\n\t\t\treturn 1;\r\n\t\t}\r\n\t\t\r\n\t\tprotected function _getFriction():Number {\r\n\t\t\t\r\n\t\t\tswitch (peObject) {\r\n\t\t\t\t{% for body in bodies %}\r\n\t\t\t\tcase \"{{body.name}}\":\r\n\t\t\t\t\t{% for fixture in body.fixtures %}return {{fixture.friction}};{% endfor %}\r\n\t\t\t\t\tbreak;\r\n\t\t\t{% endfor %}\r\n\t\t\t}\r\n\r\n\t\t\treturn 0.6;\r\n\t\t}\r\n\t\t\r\n\t\tprotected function _getRestitution():Number {\r\n\t\t\t\r\n\t\t\tswitch (peObject) {\r\n\t\t\t\t{% for body in bodies %}\r\n\t\t\t\tcase \"{{body.name}}\":\r\n\t\t\t\t\t{% for fixture in body.fixtures %}return {{fixture.restitution}};{% endfor %}\r\n\t\t\t\t\tbreak;\r\n\t\t\t{% endfor %}\r\n\t\t\t}\r\n\r\n\t\t\treturn 0.3;\r\n\t\t}\r\n\t}\r\n}<\/pre>\n<p>And finally the AS3 export file which contains a muffin and a icecream :<\/p>\n<pre lang=\"actionscript3\" line=\"1\">package {\r\n\r\n    import Box2DAS.Collision.Shapes.b2PolygonShape;\r\n\timport Box2DAS.Common.V2;\r\n\r\n\timport com.citrusengine.objects.PhysicsObject;\r\n\r\n\t\/**\r\n\t * @author Aymeric\r\n\t * <p>This is a class created by the software http:\/\/www.physicseditor.de\/<\/p>\r\n\t * <p>Just select the CitrusEngine template, upload your png picture, set polygons and export.<\/p>\r\n\t * <p>Be careful, the registration point is topLeft !<\/p>\r\n\t * @param peObject : the name of the png file\r\n\t *\/\r\n    public class PhysicsEditorObjects extends PhysicsObject {\r\n\t\t\r\n\t\t[Inspectable(defaultValue=\"\")]\r\n\t\tpublic var peObject:String = \"\";\r\n\r\n\t\tprivate var _tab:Array;\r\n\r\n\t\tpublic function PhysicsEditorObjects(name:String, params:Object = null) {\r\n\r\n\t\t\tsuper(name, params);\r\n\t\t}\r\n\r\n\t\toverride public function destroy():void {\r\n\r\n\t\t\tsuper.destroy();\r\n\t\t}\r\n\r\n\t\toverride public function update(timeDelta:Number):void {\r\n\r\n\t\t\tsuper.update(timeDelta);\r\n\t\t}\r\n\r\n\t\toverride protected function defineFixture():void {\r\n\t\t\t\r\n\t\t\tsuper.defineFixture();\r\n\t\t\t\r\n\t\t\t_createVertices();\r\n\r\n\t\t\t_fixtureDef.density = _getDensity();\r\n\t\t\t_fixtureDef.friction = _getFriction();\r\n\t\t\t_fixtureDef.restitution = _getRestitution();\r\n\t\t\t\r\n\t\t\tfor (var i:uint = 0; i < _tab.length; ++i) {\r\n\t\t\t\tvar polygonShape:b2PolygonShape = new b2PolygonShape();\r\n\t\t\t\tpolygonShape.Set(_tab[i]);\r\n\t\t\t\t_fixtureDef.shape = polygonShape;\r\n\r\n\t\t\t\tbody.CreateFixture(_fixtureDef);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n        protected function _createVertices():void {\r\n\t\t\t\r\n\t\t\t_tab = [];\r\n\t\t\tvar vertices:Vector.<V2> = new Vector.<V2>();\r\n\r\n\t\t\tswitch (peObject) {\r\n\t\t\t\t\r\n\t\t\t\tcase \"icecream\":\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(30.5\/_box2D.scale, 45.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(97.5\/_box2D.scale, 246.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(93.5\/_box2D.scale, 270.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(62.5\/_box2D.scale, 302.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(21.5\/_box2D.scale, 126.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(16.5\/_box2D.scale, 62.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(18.5\/_box2D.scale, 50.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(62.5\/_box2D.scale, 302.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(93.5\/_box2D.scale, 270.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(81.5\/_box2D.scale, 306.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(73.5\/_box2D.scale, 312.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(65.5\/_box2D.scale, 310.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(9.5\/_box2D.scale, 111.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(16.5\/_box2D.scale, 62.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(21.5\/_box2D.scale, 126.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(10.5\/_box2D.scale, 121.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(44.5\/_box2D.scale, 32.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(135.5\/_box2D.scale, 65.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(144.5\/_box2D.scale, 115.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(135.5\/_box2D.scale, 120.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(30.5\/_box2D.scale, 45.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(28.5\/_box2D.scale, 37.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(0.5\/_box2D.scale, 81.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(6.5\/_box2D.scale, 69.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(16.5\/_box2D.scale, 62.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(9.5\/_box2D.scale, 111.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(-0.5\/_box2D.scale, 97.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(82.5\/_box2D.scale, 3.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(127.5\/_box2D.scale, 42.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(135.5\/_box2D.scale, 65.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(44.5\/_box2D.scale, 32.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(51.5\/_box2D.scale, 14.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(70.5\/_box2D.scale, -0.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(151.5\/_box2D.scale, 86.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(144.5\/_box2D.scale, 115.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(135.5\/_box2D.scale, 65.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(146.5\/_box2D.scale, 73.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(129.5\/_box2D.scale, 129.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(30.5\/_box2D.scale, 45.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(135.5\/_box2D.scale, 120.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(101.5\/_box2D.scale, 241.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(97.5\/_box2D.scale, 246.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(30.5\/_box2D.scale, 45.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(129.5\/_box2D.scale, 129.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\t\r\n\t\t\t\t\tbreak;\r\n\t\t\t\r\n\t\t\t\tcase \"muffin\":\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(195.5\/_box2D.scale, 166.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(188.5\/_box2D.scale, 128.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(199.5\/_box2D.scale, 158.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(199.5\/_box2D.scale, 164.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(89.5\/_box2D.scale, -0.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(95.5\/_box2D.scale, 8.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(92.5\/_box2D.scale, 14.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(82.5\/_box2D.scale, 3.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(85.5\/_box2D.scale, -0.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(2.5\/_box2D.scale, 149.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(23.5\/_box2D.scale, 117.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(9.5\/_box2D.scale, 175.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(-0.5\/_box2D.scale, 161.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(120.5\/_box2D.scale, 71.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(120.5\/_box2D.scale, 91.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(24.5\/_box2D.scale, 223.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(18.5\/_box2D.scale, 199.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(74.5\/_box2D.scale, 92.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(96.5\/_box2D.scale, 56.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(101.5\/_box2D.scale, 56.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(113.5\/_box2D.scale, 61.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(26.5\/_box2D.scale, 251.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(24.5\/_box2D.scale, 223.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(180.5\/_box2D.scale, 202.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(174.5\/_box2D.scale, 226.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(122.5\/_box2D.scale, 283.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(72.5\/_box2D.scale, 280.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(48.5\/_box2D.scale, 273.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(32.5\/_box2D.scale, 264.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(156.5\/_box2D.scale, 273.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(122.5\/_box2D.scale, 283.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(174.5\/_box2D.scale, 226.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(172.5\/_box2D.scale, 254.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(168.5\/_box2D.scale, 264.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(76.5\/_box2D.scale, 66.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(82.5\/_box2D.scale, 60.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(96.5\/_box2D.scale, 56.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(74.5\/_box2D.scale, 92.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(72.5\/_box2D.scale, 76.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(101.5\/_box2D.scale, 34.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(97.5\/_box2D.scale, 32.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(92.5\/_box2D.scale, 14.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(95.5\/_box2D.scale, 8.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(23.5\/_box2D.scale, 117.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(34.5\/_box2D.scale, 107.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(54.5\/_box2D.scale, 97.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(74.5\/_box2D.scale, 92.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(18.5\/_box2D.scale, 199.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(9.5\/_box2D.scale, 175.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(180.5\/_box2D.scale, 202.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(24.5\/_box2D.scale, 223.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(120.5\/_box2D.scale, 91.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(154.5\/_box2D.scale, 100.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(175.5\/_box2D.scale, 114.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(188.5\/_box2D.scale, 128.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(195.5\/_box2D.scale, 166.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\tvertices = new Vector.<V2>();\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t        vertices.push(new V2(101.5\/_box2D.scale, 34.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(101.5\/_box2D.scale, 56.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(96.5\/_box2D.scale, 56.5\/_box2D.scale));\r\n\t\t\t\t\tvertices.push(new V2(97.5\/_box2D.scale, 32.5\/_box2D.scale));\r\n\t\t\t\t\t\r\n\t\t\t\t\t_tab.push(vertices);\r\n\t\t\t\t\t\r\n\t\t\t\t\tbreak;\r\n\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tprotected function _getDensity():Number {\r\n\r\n\t\t\tswitch (peObject) {\r\n\t\t\t\t\r\n\t\t\t\tcase \"icecream\":\r\n\t\t\t\t\treturn 1;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\r\n\t\t\t\tcase \"muffin\":\r\n\t\t\t\t\treturn 1;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\r\n\t\t\t}\r\n\r\n\t\t\treturn 1;\r\n\t\t}\r\n\t\t\r\n\t\tprotected function _getFriction():Number {\r\n\t\t\t\r\n\t\t\tswitch (peObject) {\r\n\t\t\t\t\r\n\t\t\t\tcase \"icecream\":\r\n\t\t\t\t\treturn 0.6;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\r\n\t\t\t\tcase \"muffin\":\r\n\t\t\t\t\treturn 0.6;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\r\n\t\t\t}\r\n\r\n\t\t\treturn 0.6;\r\n\t\t}\r\n\t\t\r\n\t\tprotected function _getRestitution():Number {\r\n\t\t\t\r\n\t\t\tswitch (peObject) {\r\n\t\t\t\t\r\n\t\t\t\tcase \"icecream\":\r\n\t\t\t\t\treturn 0.3;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\r\n\t\t\t\tcase \"muffin\":\r\n\t\t\t\t\treturn 0.3;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\r\n\t\t\t}\r\n\r\n\t\t\treturn 0.3;\r\n\t\t}\r\n\t}\r\n}<\/pre>\n<p>There are lots of vertices stuff! Don&#8217;t forget, don&#8217;t use many vertices if it isn&#8217;t really necessary. In my case, I&#8217;ve put lots of vertices for the example, but it may be quite good with 11 vertices instead of 40. You have to think about optimization, complex shape are heavy to manage for box2d.<\/p>\n<p>Finally, I would like to thanks Andreas L\u00f6w for helping me to start this template and his support on TexturePacker mac version which works really great now with SWF file!<br \/>\nOh, and I forgot to mention that <a href=\"http:\/\/citrusengine.com\/blog\/view\/citrus-engine-now-free-and-open-source\" target=\"_blank\">the CitrusEngine is now totaly free<\/a>!<\/p>\n<p><a href=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2011\/11\/citrusengine.zip\"><strong>PhysicsEditor template zip file<\/strong><\/a>.<br \/>\n<a href=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2011\/11\/PhysicsEditorExample.zip\"><strong>PhysicsEditor example zip file<\/strong><\/a>.<\/p>\n<p>One thing on my todo list is achieved now \ud83d\ude42<br \/>\nHowever you may have noticed the Inspectable metadata tag, I haven&#8217;t finish yet with this cool engine \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some months ago, I bought two softwares from code &#8216;n&#8217; web : TexturePacker to create SpriteSheet and PhysicsEditor to create easily box2d object from png file. Today, I&#8217;m happy to share my first extension \/ template for PhysicsEditor&#8217;s software : I&#8217;ve created a template to export physics object for the Citrus Engine. This is a &hellip; <a href=\"http:\/\/www.aymericlamboley.fr\/blog\/physicseditor-template-for-the-citrus-engine\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">PhysicsEditor template for the Citrus Engine<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[4,115,51,33,114],"tags":[15,27,50,34,94],"_links":{"self":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts\/467"}],"collection":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/comments?post=467"}],"version-history":[{"count":11,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts\/467\/revisions"}],"predecessor-version":[{"id":1290,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts\/467\/revisions\/1290"}],"wp:attachment":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/media?parent=467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/categories?post=467"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/tags?post=467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}