{"id":378,"date":"2009-08-13T05:00:36","date_gmt":"2009-08-13T12:00:36","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=2001"},"modified":"2009-08-13T05:00:36","modified_gmt":"2009-08-13T12:00:36","slug":"quickbox2d-connect-to-groundbody","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=378","title":{"rendered":"QuickBox2D Connect to GroundBody"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nimport com.actionsnippet.qbox.*;\r\n\r\n&#x5B;SWF (backgroundColor=0x000000, width=700, height=600)]\r\n\r\nvar sim:QuickBox2D = new QuickBox2D(this);\r\n\r\nsim.setDefault({fillColor:0x113366, fillAlpha:0.8, lineColor:0x3355AA});\r\n\r\nsim.createStageWalls();\r\n\r\nvar boxA:QuickObject = sim.addBox({x:10, y:8, width:4, height:0.5, angularDamping:1});\r\nvar boxB:QuickObject = sim.addBox({x:7, y:8, width:3, height:0.25, angle:-.5, angularDamping:1});\r\nvar boxC:QuickObject = sim.addBox({x:12, y:2, width:2, height:1});\r\n\r\nvar rev:QuickObject = sim.addJoint({type:&quot;revolute&quot;, a:boxA.body, b:sim.w.GetGroundBody()});\r\n\/\/ add a red dot to boxA\r\nwith (boxA.userData.graphics) lineStyle(), beginFill(0xFF0000), drawCircle(0,0,2);\r\n\r\nvar rev2:QuickObject = sim.addJoint({type:&quot;revolute&quot;, a:boxB.body, b:sim.w.GetGroundBody()});\r\nwith (boxB.userData.graphics) lineStyle(), beginFill(0xFF0000), drawCircle(0,0,2);\r\n\r\nsim.start();\r\nsim.mouseDrag();\r\n<\/pre>\n<p>In order to use gear joints (covered in tomorrows post) you&#8217;ll need to know how to connect to the ground body&#8230;<br \/>\n<a data-asruffle-linked=\"true\" href=\"http:\/\/www.actionsnippet.com\/swfs\/connect_to_ground.html\" target=\"blank\" \/><br \/>\nCheck out the swf&#8230;<\/a> <span class=\"asruffle-link\" data-swf=\"{&quot;url&quot;:&quot;https:\\\/\\\/actionsnippet.com\\\/swfs\\\/connect_to_ground2.swf&quot;,&quot;title&quot;:&quot;connect to ground2&quot;,&quot;width&quot;:700,&quot;height&quot;:600,&quot;missing&quot;:false,&quot;allowScriptAccess&quot;:false,&quot;backgroundColor&quot;:&quot;#000000&quot;}\"><button type=\"button\" hidden aria-expanded=\"false\">Play demo<span class=\"screen-reader-text\">: connect to ground2<\/span><\/button><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>import com.actionsnippet.qbox.*; &#x5B;SWF (backgroundColor=0x000000, width=700, height=600)] var sim:QuickBox2D = new QuickBox2D(this); sim.setDefault({fillColor:0x113366, fillAlpha:0.8, lineColor:0x3355AA}); sim.createStageWalls(); var boxA:QuickObject = sim.addBox({x:10, y:8, width:4, height:0.5, angularDamping:1}); var boxB:QuickObject = sim.addBox({x:7, y:8, width:3, height:0.25, angle:-.5, angularDamping:1}); var boxC:QuickObject = sim.addBox({x:12, y:2, width:2, height:1}); var rev:QuickObject = sim.addJoint({type:&quot;revolute&quot;, a:boxA.body, b:sim.w.GetGroundBody()}); \/\/ add a red dot to boxA with (boxA.userData.graphics) lineStyle(), [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,13,12],"tags":[3,14,15,4,16],"class_list":["post-378","post","type-post","status-publish","format-standard","hentry","category-box2d","category-motion","category-quickbox2d","tag-actionscript","tag-as3","tag-box2d","tag-flash","tag-quickbox2d"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=378"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/378\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}