ccc 模拟重力

x=x+v

v=v+gr

cc.Class({
extends: cc.Component, properties: {
velocity:{
default:null
},
grivatity:{
default:null
}, }, // use this for initialization
onLoad: function () {
this.velocity=30;
this.grivatity=-1;
}, // called every frame, uncomment this function to activate update callback
update: function (dt) {
var now=this.node.position
if(now.y<-250)
{
this.velocity=30;
}
now.y+=this.velocity;
this.velocity+=this.grivatity;
this.node.position=now; },
});
上一篇:UVA 1513 Movie collection


下一篇:HDU 1240 (简单三维广搜) Asteroids!