Physics Shape Problem, Help!

I have a problem with physics shape, trying to create a polygon shape in my floor but i’m getting some weird shapes/shadows

i got this:

local floor = display.newImageRect("street\_pattern.png", screenW, 76)  
 floor:setReferencePoint(display.BottomLeftReferencePoint)  
 floor.x, floor.y = 0, display.contentHeight  
  
 floorShape = { 0, -38, 90, -10, screenW, -10, screenW, 38, -screenW, 38, -screenW, -10, -90, -10 }  
  
 physics.addBody( floor, "static", { density=0.5, friction=0.5, bounce=0, shape=floorShape } )  

This is the shape i want to get :
http://imageshack.us/photo/my-images/703/iwantg.png/

This is the shape i’m getting :
http://imageshack.us/photo/my-images/138/getting.png/
thanks
[import]uid: 145662 topic_id: 26115 reply_id: 326115[/import]

I’m not at a machine to test on right now, but try not setting that reference point first. [import]uid: 21331 topic_id: 26115 reply_id: 105757[/import]

The shape you want has concave regions. That’s a big no-no in Box2D :slight_smile: And in most other 2D physics systems, as far as I have seen.

You’ll have to create that basic shape with 2 separate polygons (you can use one Corona physics body, just make it a multi-shape). The “peak” section would be one shape and the “floor” would be a large rectangle under it.

Also make sure that you create both shapes in clockwise coordinate order. This is a common mistake. :stuck_out_tongue:

Brent Sorrentino
Ignis Design
[import]uid: 9747 topic_id: 26115 reply_id: 105844[/import]

Do yourself a favor, either adhere to the polygon creation rules going clockwise tra la la la.
Or you could use PhysicsEditor ( www.physicseditor.de ) Import the shape, use auto trace and be done with it. Export to corona and require the lua file in your game.
This is a simple shape, so you may not want to go that route (go native if you can). I use 1000+ vertices in my levels, so it makes sense for me to use it. For something like this, it may be easier to just follow the clock wise rules and be happy :slight_smile:
ng [import]uid: 61600 topic_id: 26115 reply_id: 107449[/import]

you will have a fantastic blog here! would you prefer to make some invite posts on my web log…need someone to write my essay || help with research paper || best essay writing help || Help assignments || Article assignment examples

[import]uid: 151444 topic_id: 26115 reply_id: 109394[/import]