ccc 模拟重力 正太分布

时间:2023-03-08 17:59:01

ball.js

cc.Class({
extends: cc.Component, properties: {
x_vel:{
default:0
},
y_vel:{
default:0
},
grivatity:{
default:null
}, }, onLoad: function () { this.grivatity=-1;
}, init:function ( x_vel,y_vel) {
this.x_vel=x_vel
this.y_vel=y_vel
}, update: function (dt) { var now=this.node.position
now.y+=this.y_vel
now.x+=this.x_vel
this.y_vel+=this.grivatity
this.node.position=now //销毁
if(now.y<-320)
this.node.destroy();
},
});

Muller.js

cc.Class({
extends: cc.Component, properties: {
x_vel:{
default:0
},
y_vel:{
default:0
},
grivatity:{
default:null
}, }, onLoad: function () { this.grivatity=-1;
}, init:function ( x_vel,y_vel) {
this.x_vel=x_vel
this.y_vel=y_vel
}, update: function (dt) { var now=this.node.position
now.y+=this.y_vel
now.x+=this.x_vel
this.y_vel+=this.grivatity
this.node.position=now //销毁
if(now.y<-320)
this.node.destroy();
},
});