Eendhoorn Posted April 28, 2017 Share Posted April 28, 2017 I'm trying to make game resize appropriately to size of the window/screen. Everything's working out great, except for the tilemap. It seems like the rendering bounds are not updated. (typescript) onResize() { this.game.scale.refresh(); var newWidth = window.innerWidth / 3; var newHeight = window.innerHeight / 3; this.game.scale.setGameSize(newWidth, newHeight); this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; //need to call this to apply new size? this.game.camera.setSize(newWidth, newHeight); for (var i = 0; i < this.tilemap.layer.length; i++) { this.tilemap.layer[i].width = newWidth; this.tilemap.layer[i].resizeFrame(this.tilemap, newWidth, newHeight); this.tilemap.layer[i].crop(new Phaser.Rectangle(0, 0, newWidth, newHeight), false); this.tilemap.layer[i].updateCrop(); } this.game.camera.follow(this.player.sprite, Phaser.Camera.FOLLOW_TOPDOWN, 0.8, 0.8); } As you can see I've tried everything, I would've expected resizeFrame or crop to do something, but unfortunately they don't. Do note that the rest of the game updates the size correctly, as the fish get rendered in the widened area just fine. Any ideas how to update the tilemap to the new size? Thanks! samme 1 Link to comment Share on other sites More sharing options...
samme Posted April 29, 2017 Share Posted April 29, 2017 Try tilemapLayer.resizeWorld() Link to comment Share on other sites More sharing options...
Eendhoorn Posted April 29, 2017 Author Share Posted April 29, 2017 13 hours ago, samme said: Try tilemapLayer.resizeWorld() Doesn't work either unfortunately Link to comment Share on other sites More sharing options...
samme Posted April 29, 2017 Share Posted April 29, 2017 I think all you need is scaleMode RESIZE hooked to tilemapLayer.resize(…). All the rest you can get rid of. WombatTurkey 1 Link to comment Share on other sites More sharing options...
WombatTurkey Posted July 10, 2017 Share Posted July 10, 2017 Thanks samme. Here's a small snippet so we don't have to use keep putting in the variable names of every layer we add. game.world.children.forEach(obj => { if(obj.type == 10) obj.resize(x, y) // If a tilemap layer, resize it... }) i just stuck there on my electron "resize" event listener although, i got stuck cause i thought game.scale.setGameSize would take into account TilemapLayers lol Link to comment Share on other sites More sharing options...
harmal Posted October 26, 2017 Share Posted October 26, 2017 that looks like a really cool game. where can we find it when its ready? Link to comment Share on other sites More sharing options...
Babsobar Posted November 13, 2017 Share Posted November 13, 2017 Hey @samme; Just a question: here you're using Layer.resize alone; but have you ever used it in conjunction with the code you're using here? : I tried it and having the scale manager set as RESIZE makes the zoom code scale the whole of the game window inside the window. Link to comment Share on other sites More sharing options...
Recommended Posts