Jump to content

Center Tilemap in Canvas


Recommended Posts


I created a tile map in Tiled,then I want to display this tile map in the center of the screen. I do it as below:

let ground = this.map.createLayer('Ground');     // "map" is Phaser.Tilemap
ground.fixedToCamera = false;
ground.position.set(this.game.world.centerX, this.game.world.centerY);

But it not work. The tile map still show on the top left of the screen.

What should I do?

Link to comment
Share on other sites


Thanks for reply.

I create a text in the center of screen like this: 

this.localFontText = this.game.add.text(this.game.world.centerX, this.game.world.centerY, '测试本地字体效果', {
            font: '50px ' + Assets.CustomWebFonts.FontsFangsong.getFamily()

This works fine. But for my map, this doesn't work.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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