36 lines
958 B
JavaScript
36 lines
958 B
JavaScript
var SPEED = 3.0;
|
|
var DURATION = 2.0;
|
|
|
|
function MoveCubeCutscene(params) {
|
|
Cutscene.call(this);
|
|
this.cube = params.cube;
|
|
|
|
var startX = this.cube.position.position.x;
|
|
|
|
this.animLeft = new Animation([
|
|
{ time: 0.0, value: startX, easing: Easing.outQuad },
|
|
{ time: DURATION, value: startX - SPEED * DURATION }
|
|
]);
|
|
|
|
this.animRight = new Animation([
|
|
{ time: 0.0, value: startX - SPEED * DURATION, easing: Easing.inOutQuad },
|
|
{ time: DURATION, value: startX }
|
|
]);
|
|
}
|
|
|
|
MoveCubeCutscene.prototype = Object.create(Cutscene.prototype);
|
|
MoveCubeCutscene.prototype.constructor = MoveCubeCutscene;
|
|
|
|
MoveCubeCutscene.prototype.update = function() {
|
|
if(!this.animLeft.complete) {
|
|
this.cube.position.position.x = this.animLeft.update(TIME.delta);
|
|
} else {
|
|
this.cube.position.position.x = this.animRight.update(TIME.delta);
|
|
if(this.animRight.complete) {
|
|
Cutscene.finish();
|
|
}
|
|
}
|
|
};
|
|
|
|
module = MoveCubeCutscene;
|