nape removing body from the space

1.2k views Asked by At

When I sue the following code the body graphic is removed, however in debug mode I can still see the outline of the body which would suggest the body still exists. How do I totally remove this body?

private function updateGraphics(b:Body) {
            if (b.position.y > 360) {
play.removeChild(b.userData.graphic);

}

}
1

There are 1 answers

0
deltaluca On

Nape has nothing to do with graphics. A Body is not magically tied to the way you display it on the screen, so removing a flash displayObject from a display list cannot possibly remove the nape body from the space.

The answer, is to remove it from the nape space!

body.space = null;

is the simplest way.