grinmonk

Camera zoom on Tilemap in 2.6.2 and CE

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.

 

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.