Search code examples
chipmunk

Chipmunk: How to Update shape?


How can I update Space in chupmunk My Code is:

// left
    shape1 = cpSegmentShapeNew(edge, cpvzero, cpv(0.0f, size.height), 0.0f);
    shape1->u = 0.1f; // minimal friction on the ground
    shape1->e = 0.7f;
    cpSpaceAddStaticShape(_space, shape1); // a body can be represented by multiple shapes

    // top
    shape2 = cpSegmentShapeNew(edge, cpvzero, cpv(size.width, 0.0f), 0.0f);
    shape2->u = 0.1f;
    shape2->e = 0.7f;
    cpSpaceAddStaticShape(_space, shape2);

    // right
    shape3 = cpSegmentShapeNew(edge, cpv(size.width, 0.0f), cpv(size.width, size.height), 0.0f);
    shape3->u = 0.1f;
    shape3->e = 0.7f;
    cpSpaceAddStaticShape(_space, shape3);

    // bottom
    shape4 = cpSegmentShapeNew(edge, cpv(0.0f, size.height), cpv(size.width, size.height), 0.0f);
    shape4->u = 0.1f;
    shape4->e = 0.7f;
    cpSpaceAddStaticShape(_space, shape4);

if ball touch the Bottom shapeBall touch like thisafter collosion ball go up but the bottom shape is remove and display green line that want i do but i dont know how to remove shape from body. anyone suggestions are welcome.


Solution

  • cpSpaceRemoveStaticShape(_space, shape4);