Level class created and gravity editable.

This commit is contained in:
Mal
2020-02-16 00:53:03 +01:00
parent cec3cc726f
commit a7ecbf9d2e
20 changed files with 277 additions and 133 deletions

View File

@@ -41,7 +41,7 @@ export default class Dialog
return button;
}
createInputNumber(label, value = 0, min = 0, max = 999999)
createInputNumber(label, value = 0, min = 0, max = 999999, step = 1)
{
let htmlElement = document.createElement('div');
htmlElement.classList.add('dialog-input-area');
@@ -54,6 +54,9 @@ export default class Dialog
htmlElementInput.classList.add('dialog-input');
htmlElementInput.type = 'number';
htmlElementInput.value = value;
htmlElementInput.max = max;
htmlElementInput.min = min;
htmlElementInput.step = step;
htmlElement.appendChild(htmlElementLabel);
htmlElement.appendChild(htmlElementInput);

View File

@@ -0,0 +1,22 @@
import Dialog from "./Dialog.js";
import TilorswiftGravityUpdatedEvent from "../events/TilorswiftGravityUpdatedEvent.js";
export default class DialogGravity extends Dialog
{
constructor(gravity)
{
super();
this.setMessage('Gravitation einstellen');
this.inputGravity = this.createInputNumber('Stärke', gravity, 0, 10, 0.01);
this.createButton('Abbrechen');
this.buttonOk = this.createButton('OK');
this.buttonOk.addEventListener(
'click',
() => {
window.dispatchEvent(
new TilorswiftGravityUpdatedEvent(parseFloat(this.inputGravity.value))
);
}
)
}
}