35 lines
802 B
JavaScript
35 lines
802 B
JavaScript
var PHASE_LEFT = 0;
|
|
var PHASE_RIGHT = 1;
|
|
|
|
var SPEED = 3.0;
|
|
var DURATION = 2.0;
|
|
|
|
function MoveCubeCutscene(params) {
|
|
Cutscene.call(this);
|
|
this.cube = params.cube;
|
|
this.phase = PHASE_LEFT;
|
|
this.timer = 0.0;
|
|
}
|
|
|
|
MoveCubeCutscene.prototype = Object.create(Cutscene.prototype);
|
|
MoveCubeCutscene.prototype.constructor = MoveCubeCutscene;
|
|
|
|
MoveCubeCutscene.prototype.update = function() {
|
|
this.timer += TIME.delta;
|
|
|
|
if(this.phase === PHASE_LEFT) {
|
|
this.cube.position.position.x -= SPEED * TIME.delta;
|
|
if(this.timer >= DURATION) {
|
|
this.phase = PHASE_RIGHT;
|
|
this.timer = 0.0;
|
|
}
|
|
} else if(this.phase === PHASE_RIGHT) {
|
|
this.cube.position.position.x += SPEED * TIME.delta;
|
|
if(this.timer >= DURATION) {
|
|
Cutscene.finish();
|
|
}
|
|
}
|
|
};
|
|
|
|
module = MoveCubeCutscene;
|