addPhyBall:function()
{
this.state = BallState.ballConst.Clear;
// let vec = cc.v2(1,1);
//let velocity = vec.normalize().mulSelf(800);
this.collider = this.node.addComponent(cc.PhysicsCircleCollider);
//collider.type = cc.RigidBodyType.Dynamic;
this.collider.radius = 17;
this.collider.density = 1;
this.collider.restitution = 0.5;
this.collider.friction = 0;
this.collider.gravityScale = 10;
this.collider.body.fixedRotation = true;
this.collider.apply();
/* let l = collider.getWorldPoint();
l.x += 10;
l.y += 10;
collider.applyLinearImpulse(cc.v2(Math.random() * 100, Math.random() * 110), l);*/
//
let out = cc.v2();
this.collider.body.getWorldVector(cc.v2(this.collider.x, this.collider.y), out);
/*out.x = out.x + Math.random() * 100;
out.y = out.y =*/
this.collider.body.applyLinearImpulse(cc.v2(Math.random() * 500 - 250, Math.random() * 500), out);
// collider.applyForceToCenter(cc.v2(5, 10));
//collider.linearVelocity.y = 100;
//cc.log(" collider.radius:", collider.radius);
// collider.radius = r;
},
onBeginContact:function(contact, selfCollider, otherCollider) {
cc.audioEngine.play(this.hitwall, false, 1);
cc.log("onBeginContact");
},
我设置完后不知道 如何增加onBeginContact,下面直接加好像不行
