I want to make the ball collided with wall, but the ball just penetrate the wall. Thanks for help.
Here is the code of wall
this.circleWall=mySprite.create(‘circleWall’);
var pos=cc.p(200,200);
// create body
var radius = this.circleWall.getBoundingBox().width;
var body = new cp.Body(1, cp.momentForCircle(10, 0, radius, cp.v(0,0)) );
body.setPos( pos );
this.space.addBody( body );
// create shape
var shape = new cp.CircleShape( body, radius, cp.v(0,0));
shape.setElasticity( 1.0 );
shape.setFriction( 1.0 )
shape.setLayers(2);
this.space.addStaticShape( shape );
this.circleWall.setBody( body );
this.circleWall.setOriginalPosition(pos);
this.addChild(this.circleWall);
this.circleWall.setShape(shape);
Here is the code of ball
var sprite = mySprite.create(‘ball');
// create body
var radius = sprite.getBoundingBox().width;
var body = new cp.Body(1, cp.momentForCircle(10, 0, radius, cp.v(0,0)) );
body.setPos( 200,500 );
this.space.addBody( body );
// create shape
var shape = new cp.CircleShape( body, radius, cp.v(0,0));
shape.setElasticity( 0.00 );
shape.setFriction( 0.00 );
shape.setLayers(2);
this.space.addShape( shape );
sprite.setBody( body );
this.addChild(sprite);
sprite.setShape(shape);