HTML moving phaser into container div

后端 未结 3 742
北荒
北荒 2021-02-04 05:52

Currently making up a browser based game in phaser and trying to add it into the container div tag I\'ve created however phaser seems to be pushing itself to below

3条回答
  •  醉梦人生
    2021-02-04 06:45

    The 4th parameter to the Phaser.Game constructor is the parent container. If you leave it empty it will inject the canvas into the document body. If you give it a string, it will run a document.getElementById() on that string, and if found inject the canvas into there. If you provide it with an HTMLElement it will skip the ID check and inject the canvas into that element instead.

    So in your case specifically I would suggest you create a div with an ID, then pass that ID into the constructor.

    More details here: http://gametest.mobi/phaser/docs/Phaser.Game.html

提交回复
热议问题