MainMenuComponent.re.ts 586 B

123456789101112131415161718192021222324
  1. import * as RE from 'rogue-engine';
  2. export default class MainMenuComponent extends RE.Component {
  3. awake() {
  4. this.loadUi()
  5. }
  6. async loadUi() {
  7. let htmlContents = await (await fetch(RE.getStaticPath("mainmenu.html"))).text()
  8. RE.Runtime.uiContainer.innerHTML = htmlContents
  9. const startButton = document.getElementById("start-button")
  10. if(startButton) {
  11. startButton.addEventListener("click", this.onStartButtonClick.bind(this))
  12. }
  13. }
  14. onStartButtonClick() {
  15. RE.App.loadScene("MainScene")
  16. }
  17. }
  18. RE.registerComponent(MainMenuComponent);