Files
esengine/source/src/Math/SubpixelFloat.ts

32 lines
933 B
TypeScript
Raw Normal View History

2020-08-23 22:09:22 +08:00
module es {
/**
* 11update时添加到amount中
* :
*
* let deltaMove = this.velocity * es.Time.deltaTime;
* deltaMove.x = this._x.update(deltaMove.x);
* deltaMove.y = this._y.update(deltaMove.y);
*/
export class SubpixelFloat {
public remainder: number = 0;
/**
* amount递增余数amount设置为当前值
* @param amount
*/
public update(amount: number){
this.remainder += amount;
2020-08-28 19:12:21 +08:00
let motion = Math.floor(Math.trunc(this.remainder));
2020-08-23 22:09:22 +08:00
this.remainder -= motion;
amount = motion;
return amount;
}
/**
* 0
*/
public reset(){
this.remainder = 0;
}
}
}