Help me out with a physics shape

I'm trying to make a physics object in the shape of a star. For some reason it doesn't display correctly. I've checked the points a few times and they seem to be correct. If I remove the inner points it makes a pentagon.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
local star = display.newImage("star_1.png")
star.x = 160
star.y = 60
-- 0, -22, 8, -8, 22, -6, 12, 6, 15, 21, 0, 13, -14, 22, -11, 6, -22, -6, -7, -8
physics.addBody( star, {density=3.0, 
                                           friction=0.8, 
                                             bounce=0.3, 
                                              shape={0, -22, 
                                                         8,  -8, 
                                                        22,  -6, 
                                                        12,   6, 
                                                        15,  22, 
                                                         0,  13, 
                                                   -14,  22, 
                                                   -11,   6, 
                                                   -22,  -6, 
                                                    -7, -8} } )

I think I've found a solution. The API states:

The maximum number of points (and therefore edges) allowed per collision shape is eight. Once defined, a shape definition can be re-used multiple times.

Note that these polygon coordinates must be defined in clockwise order, and the resulting shape must be convex-only.

Seems like I have too many points and may shapes are not convex. This limits what can be made with the physics module. Is it possible to create more complex shapes?

Thanks this looks neat. I gave it a try and it crashed the first time I tried to import an image. Plus it costs money. I think I can figure this out with pencil and paper.

Physics editor or adobe fireworks (with physics shape plugin) are the easiest way to go.

Check the physics api page again, if you need more than 8 points you can add multiple shape definitions to a body

Thanks for the reply. I had not heard of the Fireworks plugin. Too bad I don't have Fireworks. I have Flash, Dreamweaver, Photoshop and Illustrator. For some reason I don't have Fireworks. I guess I didn't install it, I didn't know I would need it until now.

I figured out the complex shapes and made a few. This was pretty easy.

for physics shapes i use plugin for Adobe Frameworks

views:1324 update:2012/1/4 9:12:54
corona forums © 2003-2011