});
var PhaserGame = function () {
this.bmd = null;
this.points = {
'x': [ 32, 600 ],
'y': [ 240, 240 ]
};
};
PhaserGame.prototype = {
create: function () {
this.stage.backgroundColor = '#204090';
this.bmd = this.add.bitmapData(this.game.width, this.game.height);
this.bmd.addToWorld();
// 生成不同y位置
var py = this.points.y;
for (var i = 0; i < py.length; i++) {
py[i] = this.rnd.between(32, 432);
}
this.bmd.clear();
var x = 1 / game.width;
// 通过X轴生成路径
for (var i = 0; i <= 1; i += x) {
// 线性算法生成路径点
var px = this.math.linearInterpolation(this.points.x, i);
var py = this.math.linearInterpolation(this.points.y, i);
// 绘制线条
this.bmd.rect(px, py, 2, 2, 'rgba(255, 255, 255, 1)');
}
/* debug */
for (var p = 0; p < this.points.x.length; p++) {
this.bmd.rect(this.points.x[p]-3, this.points.y[p]-3, 6, 6, 'rgba(255, 0, 0, 1)');
}
}
};
game.state.add('Game', PhaserGame, true);