hook up pause menu actions (resume, restart, exit), but still need to force beats to reposition off audio.currentTime
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
/**
|
||||
* Pause all beats.
|
||||
*/
|
||||
AFRAME.registerComponent('beat-pauser', {
|
||||
pause: function () {
|
||||
for (let i = 0; i < this.el.children.length; i++) {
|
||||
this.el.children[i].pause();
|
||||
}
|
||||
},
|
||||
|
||||
play: function () {
|
||||
for (let i = 0; i < this.el.children.length; i++) {
|
||||
this.el.children[i].play();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,7 +1,8 @@
|
||||
AFRAME.registerComponent('saber-controls', {
|
||||
schema: {
|
||||
bladeEnabled: {default: false},
|
||||
hand: {default: 'right', oneOf: ['left', 'right']}
|
||||
hand: {default: 'right', oneOf: ['left', 'right']},
|
||||
isPaused: {default: false}
|
||||
},
|
||||
|
||||
init: function () {
|
||||
@@ -24,6 +25,9 @@ AFRAME.registerComponent('saber-controls', {
|
||||
update: function (oldData) {
|
||||
if (!oldData.bladeEnabled && this.data.bladeEnabled) {
|
||||
this.bladeEl.emit('drawblade');
|
||||
if (!oldData.isPaused) {
|
||||
this.bladeEl.emit('drawbladesound');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -12,10 +12,17 @@ AFRAME.registerComponent('song', {
|
||||
|
||||
init: function () {
|
||||
// Use audio element for audioanalyser.
|
||||
this.audio = document.createElement('audio');
|
||||
this.audio.setAttribute('id', 'song');
|
||||
this.audio.crossOrigin = 'anonymous';
|
||||
this.el.sceneEl.appendChild(this.audio);
|
||||
const audio = this.audio = document.createElement('audio');
|
||||
audio.setAttribute('id', 'song');
|
||||
audio.crossOrigin = 'anonymous';
|
||||
this.el.sceneEl.appendChild(audio);
|
||||
|
||||
this.el.addEventListener('pausemenurestart', () => {
|
||||
if (audio.paused) {
|
||||
audio.currentTime = 0;
|
||||
audio.play();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
update: function (oldData) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<audio id="introSong" src="assets/sounds/introSong.ogg" loop></audio>
|
||||
|
||||
<a-scene
|
||||
bind__beat-loader="challengeId: challenge.id; difficulty: challenge.difficulty; isPaused: isPaused"
|
||||
bind__beat-loader="challengeId: challenge.id; difficulty: challenge.difficulty; isPaused: !isPlaying"
|
||||
bind__song="challengeId: challenge.id; isPlaying: isPlaying && !challenge.isLoading"
|
||||
bind__song-preview-system="selectedChallengeId: menuSelectedChallenge.id"
|
||||
bind__overlay="enabled: !isPlaying"
|
||||
@@ -79,7 +79,7 @@
|
||||
<a-entity id="beatObjTemplate" obj-model="obj: #beatObj" visible="false"></a-entity>
|
||||
<a-entity id="dotObjTemplate" obj-model="obj: #dotObj" visible="false"></a-entity>
|
||||
|
||||
<a-entity id="beatContainer" bind__pause="isPaused: isPaused" beat-pauser></a-entity>
|
||||
<a-entity id="beatContainer" bind__pause="isPaused: !isPlaying"></a-entity>
|
||||
|
||||
<a-entity id="cursorLaser" obj-model="obj: #laserObj" visible="false"></a-entity>
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
bind__menu-controls="page: search.page; selectedChallengeId: menuSelectedChallenge.id"
|
||||
bind__pauser="enabled: isPlaying"
|
||||
bind__raycaster="enabled: {{ hand }}RaycasterActive"
|
||||
bind__saber-controls="bladeEnabled: isPlaying"
|
||||
bind__saber-controls="bladeEnabled: isPlaying; isPaused: isPaused"
|
||||
bind__trail="enabled: isPlaying"
|
||||
haptics="events: mouseenter; dur: 35; force: 0.075"
|
||||
saber-controls="hand: {{ hand }}"
|
||||
@@ -140,7 +140,7 @@
|
||||
class="blade"
|
||||
geometry="primitive: box; height: 0.9; depth: 0.02; width: 0.02"
|
||||
material="shader: flat; color: {{ bladeColor }}"
|
||||
play-sound="event: drawblade; sound: #saberDraw"
|
||||
play-sound="event: drawbladesound; sound: #saberDraw"
|
||||
position="0 -0.55 0"></a-entity>
|
||||
</a-entity>
|
||||
<a-entity
|
||||
|
||||
@@ -123,6 +123,19 @@ AFRAME.registerState({
|
||||
state.isPaused = true;
|
||||
},
|
||||
|
||||
pausemenuresume: (state) => {
|
||||
state.isPaused = false;
|
||||
},
|
||||
|
||||
pausemenurestart: (state) => {
|
||||
state.isPaused = false;
|
||||
},
|
||||
|
||||
pausemenuexit: (state) => {
|
||||
state.isPaused = false;
|
||||
state.menu.active = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Start challenge.
|
||||
* Transfer staged challenge to the active challenge.
|
||||
@@ -186,10 +199,8 @@ AFRAME.registerState({
|
||||
*/
|
||||
computeState: (state) => {
|
||||
state.isPlaying = !state.menu.active && !state.isPaused;
|
||||
state.leftRaycasterActive = state.menu.active && state.activeHand === 'left' &&
|
||||
state.inVR;
|
||||
state.rightRaycasterActive = state.menu.active && state.activeHand === 'right' &&
|
||||
state.inVR;
|
||||
state.leftRaycasterActive = !state.isPlaying && state.activeHand === 'left' && state.inVR;
|
||||
state.rightRaycasterActive = !state.isPlaying && state.activeHand === 'right' && state.inVR;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -13,15 +13,26 @@
|
||||
text="align: center; wrapCount: 17; color: #AAA"></a-mixin>
|
||||
|
||||
<a-entity id="pauseDialog" position="0 1.6 -2" bind__visible="isPaused">
|
||||
<a-entity id="continueButton" mixin="dialogButton" position="0 0.35 0">
|
||||
<a-entity mixin="dialogButtonText" text="value: CONTINUE" position="0 -0.070 0.01"></a-entity>
|
||||
<a-entity
|
||||
id="resumeButton"
|
||||
mixin="dialogButton"
|
||||
position="0 0.35 0"
|
||||
proxy-event="event: click; to: a-scene; as: pausemenuresume">
|
||||
<a-entity mixin="dialogButtonText" text="value: RESUME" position="0 -0.070 0.01"></a-entity>
|
||||
</a-entity>
|
||||
|
||||
<a-entity id="restartButton" mixin="dialogButton">
|
||||
<a-entity
|
||||
id="restartButton"
|
||||
mixin="dialogButton"
|
||||
proxy-event="event: click; to: a-scene; as: pausemenurestart">
|
||||
<a-entity mixin="dialogButtonText" text="value: RESTART SONG"></a-entity>
|
||||
</a-entity>
|
||||
|
||||
<a-entity id="exitButton" mixin="dialogButton" position="0 -0.35 0">
|
||||
<a-entity
|
||||
id="exitButton"
|
||||
mixin="dialogButton"
|
||||
position="0 -0.35 0"
|
||||
proxy-event="event: click; to: a-scene; as: pausemenuexit">
|
||||
<a-entity mixin="dialogButtonText" text="value: EXIT TO MENU" position="0 -0.070 0.01"></a-entity>
|
||||
</a-entity>
|
||||
</a-entity>
|
||||
|
||||
Reference in New Issue
Block a user