m7_b5 Posted February 19, 2017 Share Posted February 19, 2017 Hey guys, I'm trying to build a top down style game using a tilemap made in Tiled using 64 x 64 size tilemap (100 tiles x 100 tiles). I want to scale it down to 32 x 32 sized tiles and then scale my sprites depending on the device. In any case, just using layer.setScale(.5) on each layer of the map seems to actually work, except, some other funky results happen. I am fairly new to phaser so I wanted to see if anyone had a thought on what I might be doing wrong here. What ends up happening is that the tiles do indeed resize and don't look horrible. The camera & canvas has stayed the same size. However, the area where the tiles are actually drawn was also reduced by .5. See screen shot (please don't laugh at my lame hand made graphics lol) THe desire is to have it all 32 x 32 just automatically scaled while preserving the display size. Here's the code: In preload game.load.tilemap('Level1', 'img/Tiles/Level1.json', null, Phaser.Tilemap.TILED_JSON); game.load.image('Level1Tiles', 'img/Tiles/Level1Tiles.png'); Here is where I init the map function initTileMap() { map = game.add.tilemap('Level1'); map.addTilesetImage('Level1Tiles', 'Level1Tiles'); var walls = map.createLayer('Walls'); walls.setScale(.5); collisionLayer = map.createLayer('Collision'); collisionLayer.setScale(.5); collisionLayer.visible = false; map.setCollisionByExclusion([], true, collisionLayer); collisionLayer.resizeWorld(); var stuffLayer = map.createLayer('Stuff'); stuffLayer.setScale(.5); map.tileHeight = 32; map.tileWidth = 32; } The last two lines there were just trying to fix the bug. I noticed when looking at the objects in memory that those didn't get changed with the modification of the layers. Any thoughts on this? Thanks Link to comment Share on other sites More sharing options...
m7_b5 Posted February 20, 2017 Author Share Posted February 20, 2017 an update: I've tried a bunch of things to fix this, but as of yet no solution. The one thing that I notice is that the odd sizing for the space that is actually rendered shows only in 1 place - on the _bounds property of the game.world object. That is showing a phaser rectangle object with w/h of 366 x 406, matching the display in the images in my post above. The actual game.world.height & width are correct, but that _bounds object is not. I also tried removing collisionLayer.reiszeWorld(); call, and when that didn't work I also tried leaving it out but adding a separate game.world.resize(732,412) just to see if it would fix the issue. But the end result is the same. Any help/thoughts on this would be most appreciated. Thanks! Link to comment Share on other sites More sharing options...
squilibob Posted February 21, 2017 Share Posted February 21, 2017 I'm not sure if you're going about this the right way. Shouldn't you just be resizing the map and not the layers? function initTileMap() { map = game.add.tilemap('Level1', width, height, tileWidth, tileHeight, var mapgroup = game.add.group()); map.addTilesetImage('Level1Tiles', 'Level1Tiles'); mapgroup.scale.setTo(0.5); var walls = map.createLayer('Walls'); collisionLayer = map.createLayer('Collision'); collisionLayer.visible = false; map.setCollisionByExclusion([], true, collisionLayer); collisionLayer.resizeWorld(); var stuffLayer = map.createLayer('Stuff'); } Link to comment Share on other sites More sharing options...
m7_b5 Posted February 22, 2017 Author Share Posted February 22, 2017 Gave that a shot. What ends up happening is that it pretty much ignores the mapgroup.scale. Everything is the original size. I figure I can either start debugging the phaser library itself to see what is going on under the hood, or I can just automate some process when doing my graphics creation to save off 32x32 versions of everything as I create them, then sniff and use the size that is appropriate based on the device. That may end up being my way out, but jeez I was hoping to have just a single set of sprite sheets and tilemaps Link to comment Share on other sites More sharing options...
Recommended Posts