Jump to content

Camera zoom on Tilemap in 2.6.2 and CE


grinmonk
 Share

Recommended Posts

I'm trying to zoom camera (change its scale) while focused on a player on a tilemap.

        const speed = 0.01;
        
        if (this.cursors.up.isDown) {
            this.game.camera.scale.add(speed,  speed);
        }
        else if (this.cursors.down.isDown) {
            this.game.camera.scale.add(-speed,  -speed);
        }

This is how I create the map:

        this.map16 = this.game.add.tilemap("tilemap16");
        this.map16.addTilesetImage("xrpg_tileset", "tileset16");
        this.wallsLayer = this.map16.createLayer('Walls');

 

Both player object and the map layers are placed in the World. But it seems that tilemap layer's position is affected by camera's zoom which looks wrong:

https://gph.is/2HuEeDk

 

To check if something is wrong with the scene I replaced the map with an image and zoom worked correctly:

https://gph.is/2KitDZL

 

The behaivor is identical in 2.6.2 and 2.10.3.

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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