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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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