Cocos2d Chipmunk: Custom shapes?

584 Views Asked by At

In my application i try to make custom shapes by using addPoly, but it doesen't seem to work at all! :(

I think i don't understand how to use it at all... :(

Here's my attempt of creating a simple square:

cpShape *square = [smgr addPolyAt:cpv(240,160) mass:100 rotation:0 numPoints:4 points:cpv(0, -10), cpv(10, 0), cpv(0, 10), cpv(-10, 0)];

I just don't get how to use it; can you help me plz???

1

There are 1 best solutions below

2
On BEST ANSWER

try these points: cpv(0, 0), cpv(10, 0), cpv(10, -10), cpv(0, -10) Remember you can't create the polygon counterclockwise (always clockwise) and you can't just add the points in any order! By the way if you don't have a sprite associated to the shape use [self addChild:[smgr createDebugLayer]]; to show the shape in the simulator. Greetings Alex...feel free to ask any follow up questions