kittykatattack / hexi

Make games the fun way!
MIT License
551 stars 83 forks source link

Specify the game container #49

Closed thomasverleye closed 2 years ago

thomasverleye commented 6 years ago

Is there any way to add the canvas element in a specific div? Hexi creates the div directly inside the body but I'd need to put this elsewhere because of styling reasons.

thomasverleye commented 6 years ago
if (document.getElementsByClassName('js-game-container').length > 0) {
  //move the canvas element inside the game container
  document.getElementsByClassName('js-game-container')[0].appendChild(g.canvas)
}

This did the trick for me :-)

kittykatattack commented 6 years ago

@thomasverleye Thank you for posting this! This indeed is a feature I need to add to Hexi - I had the same problem a few weeks ago on one of my own projects! Glad you found a workaround 😄