Jump to content

Question about const's


Damian Pastorini
 Share

Recommended Posts

Hi everyone, 

My name is Damian, I'm new in Phaser.

I was working with a code sample that has the following:

    <script>
        const WEBGL_RENDERER = true;
        const CANVAS_RENDERER = true;
    </script>
    <script type="text/javascript" src="./client.js"></script>

I'm really not sure for what are the const's, I'm working in a "2d-titled" game and nothing changes if I comment both.

Any recommendations or clue about if I should keep them and why?

Thanks!

Link to comment
Share on other sites

WebGL just increases performance of your game.

Canvas rendering is the slower option.

 

I have never seen setting this constants manually. I always set them in the "config" variable.

 

var config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    scene: {
        preload: preload,
        create: create,
        update: update
    }
};

var game = new Phaser.Game(config);

The type "Phaser.AUTO" automatically tries to use WebGL, but if the browser doesn't support it it'll fall back to Canvas rendering.

 

If you set the correct type in the config variable i think you can delete the two lines, but maybe a phaser expert knows more than I.

Link to comment
Share on other sites

Well... I'm using Parcel but I think it's for rebuild Phaser itself but to rebuild the code I use that implements Phaser.

I'll share with you the game-base once it's relative working (is a Colyseus + MySQL + Phaser 3 implementation for a MMORPG), hopefully I will get some feedback as good as yours :)

Thanks both!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...