{"id":326,"date":"2009-06-25T18:17:24","date_gmt":"2009-06-26T01:17:24","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=1630"},"modified":"2009-06-25T18:17:24","modified_gmt":"2009-06-26T01:17:24","slug":"quickbox2d-groupindex","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=326","title":{"rendered":"QuickBox2D groupIndex"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nimport com.actionsnippet.qbox.*;\r\nimport Box2D.Common.Math.*;\r\n\r\nstage.frameRate = 60;\r\n\r\nvar sim:QuickBox2D = new QuickBox2D(this);\r\n\r\nsim.createStageWalls();\r\n\r\ncreateTraveler(3, 3);\r\n\r\naddObstacles();\r\n\r\nfunction addObstacles():void{\r\n\tsim.setDefault({groupIndex:-1, density:0, height:0.4});\r\n\tsim.addBox({x:6, y:5, width:8, angle:0.17})\r\n    sim.addBox({x:7, y:7.1, width:8, angle:-0.17})\r\n\tsim.addBox({x:5, y:9.1, width:8,  angle:0.10})\r\n\tsim.addBox({x:6, y:11.5, width:8.9,  angle:-0.20})\r\n\tsim.addBox({x:5.5, y:16, width:9, angle:0.20})\r\n\tsim.addBox({x:5.5, y:18, width:9})\r\n\tsim.addCircle({x:11, y:20, radius:2.5, groupIndex:1});\r\n\tsim.addBox({x:16, y:19, width:2, height:2, angle:0.0, groupIndex:1})\r\n}\r\n\r\nfunction createTraveler(x:Number, y:Number):QuickObject{\r\n\tvar parts:Array = &#x5B;];\r\n\tparts&#x5B;0] = sim.addCircle({x:0, y:1, radius:0.25, friction:0.01});\r\n\tparts&#x5B;1] = sim.addCircle({x:0, y:3, radius:0.25, friction:0.01});\r\n\tparts&#x5B;2] = sim.addBox({x:0, y:2, width:0.3, height:1.5 , groupIndex:-1});\r\n\treturn sim.addGroup({objects:parts, x:x, y:y });\r\n}\r\n\r\nsim.start();\r\nsim.mouseDrag();\r\n<\/pre>\n<p>One of the more advanced and useful properties of rigid bodies is the groupIndex. It allows you to specify which rigid bodies collide with one another and which rigid bodies pass through one another. This snippit demo&#8217;s the groupIndex property. For more information take a look at what <a href=\"http:\/\/www.box2d.org\/manual.html#d0e845\">the Box2D manual says<\/a>.<\/p>\n<p><a data-asruffle-linked=\"true\" href=\"https:\/\/actionsnippet.com\/swfs\/groupindex_demo.html\" target=\"blank\">Take a look at the swf here.<\/a> <span class=\"asruffle-link\" data-swf=\"{&quot;url&quot;:&quot;https:\\\/\\\/actionsnippet.com\\\/swfs\\\/groupindex_demo.swf&quot;,&quot;title&quot;:&quot;groupindex demo&quot;,&quot;width&quot;:800,&quot;height&quot;:600,&quot;missing&quot;:false,&quot;allowScriptAccess&quot;:false,&quot;backgroundColor&quot;:&quot;#ffffff&quot;}\"><button type=\"button\" hidden aria-expanded=\"false\">Play demo<span class=\"screen-reader-text\">: groupindex demo<\/span><\/button><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>import com.actionsnippet.qbox.*; import Box2D.Common.Math.*; stage.frameRate = 60; var sim:QuickBox2D = new QuickBox2D(this); sim.createStageWalls(); createTraveler(3, 3); addObstacles(); function addObstacles():void{ sim.setDefault({groupIndex:-1, density:0, height:0.4}); sim.addBox({x:6, y:5, width:8, angle:0.17}) sim.addBox({x:7, y:7.1, width:8, angle:-0.17}) sim.addBox({x:5, y:9.1, width:8, angle:0.10}) sim.addBox({x:6, y:11.5, width:8.9, angle:-0.20}) sim.addBox({x:5.5, y:16, width:9, angle:0.20}) sim.addBox({x:5.5, y:18, width:9}) sim.addCircle({x:11, y:20, radius:2.5, groupIndex:1}); sim.addBox({x:16, y:19, width:2, height:2, angle:0.0, groupIndex:1}) } [&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-326","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\/326","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=326"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/326\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}