excaliburjs / Excalibur

🎮 Your friendly TypeScript 2D game engine for the web 🗡️
https://excaliburjs.com
BSD 2-Clause "Simplified" License
1.82k stars 188 forks source link

Play button is not cleaned up on stop #1431

Closed kamranayub closed 3 years ago

kamranayub commented 4 years ago

Steps to Reproduce

  1. Create a game
  2. Start the game
  3. Stop the game

Expected Result

Play button should disappear/be cleaned up

Actual Result

Play button sticks around

Environment

Current Workaround

Target HTML element manually and delete from DOM

kamranayub commented 3 years ago

This is still an issue, if you don't click the play button. I think engine needs to call dispose whenever stop is called 😄

kamranayub commented 3 years ago

Workaround:

function cleanUpPlayButtons() {
  const playButtons = document.querySelectorAll("#excalibur-play-root");

  playButtons.forEach((playButton) => {
    if (playButton.parentNode) {
      playButton.parentNode.removeChild(playButton);
    }
  });
}