const {ccclass,property}=cc._decorator;
@ccclass
export default class Test extends cc.Component{
@property({type:cc.RigidBody,visible:true})
private _rigidBody:cc.RigidBody=null;
onLoad(){
this._rigidBody.enabledContactListener=true;
//手动添加onPreSolve回调,使用bind方法绑定this或Lambed表达式,否则this会丢失
this._rigidBody.onPreSolve=this.onBodyPreSolve.bind(this);
/*this._rigidBody.onPreSolve=(contact:cc.PhysicsContact,selfCollider:cc.PhysicsCollider,otherCollider:cc.PhysicsCollider)=>{
this.onBodyPreSolve(contact,selfCollider,otherCollider);
};*/
}
private onBodyPreSolve(contact:cc.PhysicsContact,selfCollider:cc.PhysicsCollider,otherCollider:cc.PhysicsCollider):void{
}
}