game over slow down fx (fixes #39)

This commit is contained in:
Diego F. Goberna
2018-10-09 21:36:35 +02:00
parent f9604ace05
commit b7e36bf760
13 changed files with 198 additions and 9 deletions

View File

@@ -24,8 +24,10 @@ AFRAME.registerComponent('beat-loader', {
this.bpm = undefined;
this.first = null;
this.lastTime = undefined;
this.speed = 1.0; // for slowing down on gameover
this.el.addEventListener('cleargame', this.clearBeats.bind(this));
this.el.addEventListener('slowdown', this.slowDown.bind(this));
},
update: function (oldData) {
@@ -84,6 +86,8 @@ AFRAME.registerComponent('beat-loader', {
var msPerBeat;
var noteTime;
delta *= this.speed;
if (this.data.isPaused || !this.data.challengeId || !this.beatData || !audioEl) { return; }
notes = this.beatData._notes;
@@ -195,8 +199,13 @@ AFRAME.registerComponent('beat-loader', {
this.audioSync = null;
this.first = null;
this.lastTime = 0;
this.speed = 1.0;
for (let i = 0; i < this.beatContainer.children.length; i++) {
this.beatContainer.children[i].components.beat.returnToPool(true);
}
},
slowDown: function (ev) {
this.speed = ev.detail.progress;
}
});