clean up state

This commit is contained in:
Kevin Ngo
2018-10-09 17:17:41 -07:00
parent 3efc816a5b
commit 52b9b19cf5
5 changed files with 14 additions and 15 deletions

View File

@@ -1,25 +1,27 @@
AFRAME.registerComponent('gameover', {
schema: {
start: {default: false},
reset: {default: false}
isGameOver: {default: false}
},
init: function () {
this.beatContainer = document.getElementById('beatContainer');
},
update: function (oldData) {
var data = this.data;
if (data.start){
if (!oldData.isGameOver && this.data.isGameOver){
console.log('starting slow down...');
this.el.sceneEl.setAttribute('stage-colors', 'red');
this.countDown = 1;
this.lastTime = performance.now();
}
if (data.reset && data.reset !== oldData.reset){
if (oldData.isGameOver && !this.data.isGameOver){
this.resetStage();
}
},
tick: function (time, delta) {
if (!this.data.start) return;
if (!this.data.isGameOver) { return; }
if (this.countDown >= 0){
this.el.sceneEl.emit('slowdown', {progress: this.countDown});
//this.beatContainer.object3D.position.z = -Math.pow(1 - this.countDown, 2) * 1.5;
@@ -37,4 +39,4 @@ AFRAME.registerComponent('gameover', {
this.el.sceneEl.systems.beat.speed = 1.0;
this.el.sceneEl.setAttribute('stage-colors', 'blue');
}
});
});