22 lines
588 B
JavaScript
22 lines
588 B
JavaScript
import { Vector2 } from './Vector2.js';
|
|
import { Direction } from './types/Direction.js';
|
|
export class GameInput {
|
|
constructor(touchRing) {
|
|
this.touchRing = touchRing;
|
|
this.currentInput = {
|
|
direction: Direction.None,
|
|
speedFactor: 1,
|
|
normalizedPosition: new Vector2(0, 0)
|
|
};
|
|
this.initEvents();
|
|
}
|
|
initEvents() {
|
|
this.touchRing.addEventListener('touchChange', (event) => {
|
|
this.currentInput = event.detail;
|
|
});
|
|
}
|
|
getCurrentInput() {
|
|
return this.currentInput;
|
|
}
|
|
}
|