Hi! I’ve recently started working on my firs game for mobile devices using this awesome engine and I’ve encounered some difficulties with creating a physical objects in my game. The thing is that when I use the following code I use cpVert array of 4 points and then the cpShape would be a rectangle.
So as it’s just a rectangle it behaves as a rectangle but the image in the space is a cloud. Basically this cloud has a non-rectangle shape and I’d like it to behave as ab object of an irregular shape. Is there any methods to calculate cpVect verts[] = array from textures or what else can I do for my purpose?
Thanks in advance!
I’d really appreciate your help!
@ CPhiysicsSprite* Sprite = new CPhiysicsSprite;
CCSize size = pNode~~>getTexture~~>getContentSize;
Sprite~~>initWithTexture);
Sprite~~>autorelease();
Sprite~~>setScale;
pNode~~>addChild(Sprite);
Sprite~~>setPosition;
int num = 4;
cpVect verts[] = {
cpv,
cpv,
cpv,
cpv,
};
float mass = 3.0f;
cpBody *body = cpBodyNew);
body~~>p = cpv(pos.x, pos.y);
cpSpaceAddBody(m_pSpace, body);
cpShape* shape = cpPolyShapeNew(body, num, verts, cpvzero);
shape~~>e = 0.5f; shape~~>u = 0.5f;
cpSpaceAddShape(m_pSpace, shape);
Sprite->setPhysicsBody(body);
cpBodyApplyForce(body,cpv(0,1000),cpvzero);@