Adapt canvas to the screen

0

I have a canvas with phaser with the following dimensions:

game = new Phaser.Game(480, 600, Phaser.AUTO, "");

This I show on the computer and there is no problem, it is the measurement I need, but when I visualize it from the mobile I would like it to adapt to the width of the screen.

Right now on the mobile it looks like small, and you have to zoom with your fingers to adapt it. The idea is to take the width of the screen and the content was well adjusted.

On the other hand. The canvas is called from an .html with a script:

<script src="phaser.min.js"></script>
<script src = "game.js"></script>

And in the <body> of that file .html the canvas is generated, that means that everything you type in the <body> always appears above the canvas. Is there any way to place the canvas somewhere else that I want within <body> .

Thank you very much as always!

    
asked by Jok 23.10.2018 в 23:17
source

1 answer

0

In the part of the config you add parent: 'game', I mean it would be something like this:

var config = {
        type: Phaser.AUTO,
        parent: 'juego',
        width: 800,
        height: 600,
        physics: { ...

And you call it from the html with a div as follows: <div id="juego"></div>.

    
answered by 06.11.2018 в 04:16