Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tilemap no longer works with Canvas #5480

Closed
marshmn opened this issue Dec 30, 2020 · 2 comments
Closed

Tilemap no longer works with Canvas #5480

marshmn opened this issue Dec 30, 2020 · 2 comments

Comments

@marshmn
Copy link

marshmn commented Dec 30, 2020

Version

  • Phaser Version: 3.50.1
  • Operating system: Linux
  • Browser: Chrome 86.0.4240.198

Description

It appears that tilemap (from Tiled JSON) no longer work with Canvas display. Seems to work in WebGL.

This was working fine with Canvas in 3.24.1 but seems to have broken since.

Can be reproduced by taking the following example and switching to Canvas instead of WebGL: https://phaser.io/examples/v3/view/tilemap/tiled-json-map

Example Test Code

var config = {
    type: Phaser.CANVAS,
    width: 800,
    height: 600,
    backgroundColor: '#2d2d2d',
    parent: 'phaser-example',
    pixelArt: true,
    scene: {
        preload: preload,
        create: create,
        update: update
    }
};

var game = new Phaser.Game(config);
var controls;

function preload ()
{
    this.load.image('tiles', 'assets/tilemaps/tiles/cybernoid.png');
    this.load.tilemapTiledJSON('map', 'assets/tilemaps/maps/cybernoid.json');
}

function create ()
{
    var map = this.make.tilemap({ key: 'map' });

    // The first parameter is the name of the tileset in Tiled and the second parameter is the key
    // of the tileset image used when loading the file in preload.
    var tiles = map.addTilesetImage('cybernoid', 'tiles');

    // You can load a layer from the map using the layer name from Tiled, or by using the layer
    // index (0 in this case).
    var layer = map.createLayer(0, tiles, 0, 0);

    this.cameras.main.setBounds(0, 0, map.widthInPixels, map.heightInPixels);

    var cursors = this.input.keyboard.createCursorKeys();
    var controlConfig = {
        camera: this.cameras.main,
        left: cursors.left,
        right: cursors.right,
        up: cursors.up,
        down: cursors.down,
        speed: 0.5
    };
    controls = new Phaser.Cameras.Controls.FixedKeyControl(controlConfig);

    var help = this.add.text(16, 16, 'Arrow keys to scroll', {
        fontSize: '18px',
        padding: { x: 10, y: 5 },
        backgroundColor: '#000000',
        fill: '#ffffff'
    });
    help.setScrollFactor(0);
}

function update (time, delta)
{
    controls.update(delta);
}

Additional Information

@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

@marshmn
Copy link
Author

marshmn commented Jan 8, 2021

Sorry, I didn't get chance to test this before you released 3.51 - but I've now tested with that and confirm that everything is working for me now 👍

Thanks for the speedy fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants