Add mines
This commit is contained in:
@@ -22,6 +22,7 @@ AFRAME.registerComponent('beat-loader', {
|
||||
this.beatContainer = document.getElementById('beatContainer');
|
||||
this.bpm = undefined;
|
||||
this.beatsTime = undefined;
|
||||
this.onKeyDown = this.onKeyDown.bind(this);
|
||||
|
||||
this.el.addEventListener('cleargame', this.clearBeats.bind(this));
|
||||
},
|
||||
@@ -54,6 +55,30 @@ AFRAME.registerComponent('beat-loader', {
|
||||
xhr.send();
|
||||
},
|
||||
|
||||
onKeyDown: function (event) {
|
||||
var keyCode = event.keyCode;
|
||||
switch (keyCode) {
|
||||
case 32: // Space
|
||||
this.generateBeat({
|
||||
_lineIndex: 2,
|
||||
_lineLayer: 1,
|
||||
_cutDirection: 1,
|
||||
_type: 3
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
play: function () {
|
||||
window.addEventListener('keydown', this.onKeyDown);
|
||||
},
|
||||
|
||||
pause: function () {
|
||||
window.removeEventListener('keydown', this.onKeyDown);
|
||||
},
|
||||
|
||||
/**
|
||||
* Load the beat data into the game.
|
||||
*/
|
||||
|
||||
@@ -101,12 +101,12 @@ AFRAME.registerComponent('beat', {
|
||||
blockEl.object3D.scale.multiplyScalar(3.45).multiplyScalar(this.data.size);
|
||||
|
||||
if (this.data.type === 'mine') {
|
||||
let model = evt.detail.model.children[0];
|
||||
model.material = this.el.sceneEl.components.stagecolors.mineMaterial;
|
||||
let model = blockEl.getObject3D('mesh');
|
||||
model.material = this.el.sceneEl.components['stage-colors'].mineMaterial;
|
||||
} else {
|
||||
signEl.setAttribute('material', SIGN_MATERIAL);
|
||||
this.setObjModelFromTemplate(signEl, this.signModels[this.data.type]);
|
||||
}
|
||||
|
||||
signEl.setAttribute('material', SIGN_MATERIAL);
|
||||
this.setObjModelFromTemplate(signEl, this.signModels[this.data.type]);
|
||||
},
|
||||
|
||||
initColliders: function () {
|
||||
|
||||
Reference in New Issue
Block a user