Majirefy Posted February 25, 2017 Report Share Posted February 25, 2017 Hi! 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); ground.anchor.setTo(0.5); But it not work. The tile map still show on the top left of the screen. What should I do? Quote Link to comment Share on other sites More sharing options...
ldd Posted February 25, 2017 Report Share Posted February 25, 2017 https://phaser.io/examples/v2/sprites/anchor Maybe your anchor is wrong. More importantly, `game.world.width` may be much bigger than `game.width` So try this.game.width/2 and this.game.height/2. and make sure that position (0,0) is actually the top left of the screen (It is entirely possible that part of your world is to the left) Quote Link to comment Share on other sites More sharing options...
Majirefy Posted February 25, 2017 Author Report Share Posted February 25, 2017 @ldd 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.localFontText.anchor.setTo(0.5); This works fine. But for my map, this doesn't work. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.