feat: wheel changes active slot
This commit is contained in:
parent
bbdd74f7e0
commit
79b8039937
|
@ -87,7 +87,6 @@ export class App extends decorate(class {}) {
|
|||
this.onBlur = this.onBlur.bind(this);
|
||||
this.onFocus = this.onFocus.bind(this);
|
||||
// Global keys.
|
||||
this.stage.on('keyDown', this.onGlobalKeydown, this);
|
||||
this.pointingAt = [-1, -1];
|
||||
this.pointerMovementHandle = undefined;
|
||||
// Net.
|
||||
|
@ -231,7 +230,7 @@ export class App extends decorate(class {}) {
|
|||
this.isFocused = true;
|
||||
}
|
||||
|
||||
onGlobalKeydown(key) {
|
||||
onKeyDown(key) {
|
||||
switch (key) {
|
||||
case 'F2':
|
||||
this.isDebugging = !this.isDebugging;
|
||||
|
@ -337,6 +336,19 @@ export class App extends decorate(class {}) {
|
|||
}
|
||||
}
|
||||
|
||||
onWheel(event) {
|
||||
if (!this.selfEntity) {
|
||||
return;
|
||||
}
|
||||
const activeSlotIndex = this.selfEntity.activeSlotIndex;
|
||||
if (event.deltaY > 0) {
|
||||
this.selfEntity.activeSlotIndex = (activeSlotIndex + 1) % 10;
|
||||
}
|
||||
else if (event.deltaY < 0) {
|
||||
this.selfEntity.activeSlotIndex = (activeSlotIndex + 9) % 10;
|
||||
}
|
||||
}
|
||||
|
||||
// Stub for now!
|
||||
readConfig() {
|
||||
return {
|
||||
|
@ -426,9 +438,11 @@ export class App extends decorate(class {}) {
|
|||
startProcessingInput() {
|
||||
const config = this.readConfig();
|
||||
// Pointer input.
|
||||
this.stage.on('keyDown', this.onKeyDown, this);
|
||||
this.stage.on('pointerDown', this.onPointerDown, this);
|
||||
this.stage.on('pointerMove', this.onPointerMove, this);
|
||||
this.stage.on('pointerUp', this.onPointerUp, this);
|
||||
this.stage.on('wheel', this.onWheel, this)
|
||||
// Lol, Apple...
|
||||
window.addEventListener('touchmove', (event) => {
|
||||
event.preventDefault();
|
||||
|
@ -527,9 +541,11 @@ export class App extends decorate(class {}) {
|
|||
this.inputHandle = undefined;
|
||||
this.stage.element.removeEventListener('focus', this.onFocus);
|
||||
this.stage.element.removeEventListener('blur', this.onBlur);
|
||||
this.stage.off('pointerUp', this.onPointerUp, this);
|
||||
this.stage.off('pointerMove', this.onPointerMove, this);
|
||||
this.stage.off('pointerDown', this.onPointerDown, this);
|
||||
this.stage.off('keyDown', this.onKeyDown);
|
||||
this.stage.off('pointerUp', this.onPointerUp);
|
||||
this.stage.off('pointerMove', this.onPointerMove);
|
||||
this.stage.off('pointerDown', this.onPointerDown);
|
||||
this.stage.off('wheel', this.onWheel);
|
||||
}
|
||||
|
||||
stopRendering() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user