Владислав
Владислав

Reputation: 297

Interacting Phaser 3 with Dom

I create a canvas field using Phaser 3. And this field is added to the end of the body. How can I add it to any div?

Upvotes: 3

Views: 590

Answers (1)

brae
brae

Reputation: 1122

You can place the Phaser canvas in a specific <div> by adding an id to the <div> and referencing it as the parent in your Phaser game configuration.

<div id="gameContainer"></div>
config = {
  type: Phaser.CANVAS,
  ...
  parent: 'gameContainer'
};

Upvotes: 3

Related Questions