Files
junisaber/src/components/pauser.js
Diego F. Goberna 3efc816a5b cleanup
2018-10-10 02:06:01 +02:00

30 lines
530 B
JavaScript

const events = [
'menudown',
'abuttondown',
'bbuttondown',
'xbuttondown',
'ybuttondown'
];
/**
* Tell app to pause game if playing.
*/
AFRAME.registerComponent('pauser', {
schema: {
enabled: {default: true}
},
init: function () {
this.pauseGame = this.pauseGame.bind(this);
events.forEach(event => {
this.el.addEventListener(event, this.pauseGame);
});
},
pauseGame: function () {
if (!this.data.enabled) { return; }
this.el.sceneEl.emit('pausegame', null, false);
}
});