The same amount of screen space, regardless of amount tiles

Good afternoon, I am completely new in working with Phaser, but for a long time I tried unsuccessfully to find a solution myself ! :slight_smile:

The concept of the game is a clone of Battle City (Tanks) from the NES, BUT with a player-generated map size and number of units, that reading from JSON.

My question is: how to make the game-location take up the same amount of screen space, regardless of its size (10x10 tiles, 100x100 tiles or something other)?

Should I somehow convert Tilemap, Tilelayer or use Camera methods? I heard, that Phaser 3 has svg-support, maybe I need to use it and change the size of tiles depending on the incoming value from JSON?

Thanks for help! And sorry for my language! :wink:

Recently I’ve had to scale my game bigger/smaller based on player input as well, so this is my suggestion, hopefully it will be useful.

When you first generate the tiles, make sure your first object’s position is something that will never change

  • example, your center-most tile.

Set that to world.centerX, world.centerY and create the rest of the tiles and objects relative to that object’s position

  • example, the tile beside it could be Tile2.x = CenterTile.x + CenterTile.width/2

By creating all the objects relative to that one tile’s position, all you need to do to make it ‘scale down / up’ now is to simply; create and use smaller sprites when the map consists of more tiles and bigger sprites when the map consists of less tiles.

Hopefully this made sense to you, please feel free to ask me to clarify on anything you are unclear of.

Thanks for answering, but i don’t I could not do it in this way(

I solved my problem in a rougher, but easier way: add this.game.renderer.resize() and count size for every size of map on initialization game

Ahhh glad you managed to find a solution! Thanks for sharing :sunny: