hellos3b Posted November 30, 2014 Share Posted November 30, 2014 So I have a little top-view action game going on, with a 40x40 tilemap made with Tiled that describes the world. Right now, I just initiated it and added it to the worlddefine(['phaser'],function(Phaser) { var map; return { preload: function(game) { game.load.tilemap('forest-map', '/assets/tilemap/forest.json', null, Phaser.Tilemap.TILED_JSON); game.load.image('forest-tiles', 'assets/img/forest.png'); }, create: function(game, name) { map = window._map = game.add.tilemap('forest-map'); map.addTilesetImage('forest', 'forest-tiles'); var layer = map.createLayer('grass2'); layer.fixedToCamera = false; layer.resizeWorld(); layer.debug = true; } };});(Side note: I went through a lot of phaser source and saw fixedToCamera was true by default, but none of the examples even have a mention of it) The player should be able adventure out into the world -- but as soon as it starts scrolling you see the end of the TileMap, as if it never got made outside of the original viewport (Left is game, right is in Tiled) Am I missing something? Link to comment Share on other sites More sharing options...
JUL Posted December 1, 2014 Share Posted December 1, 2014 Probably.http://examples.phaser.io/_site/view_full.html?d=games&f=starstruck.js&t=starstruck Bottom of page. Link to comment Share on other sites More sharing options...
hellos3b Posted December 1, 2014 Author Share Posted December 1, 2014 I don't see what you're referring to? My current fix was to add the width&height parameters to the layout - var layer = window._layer = map.createLayer('Bottom', 1800, 1800);but the comments in the function call warn you. * @param {number} [width] - The rendered width of the layer, should never be wider than Game.width. If not given it will be set to Game.width. * @param {number} [height] - The rendered height of the layer, should never be wider than Game.height. If not given it will be set to Game.height. Link to comment Share on other sites More sharing options...
xerver Posted December 2, 2014 Share Posted December 2, 2014 Have you tried my plugin for phaser that makes rendering Tiled maps smoother? https://github.com/englercj/phaser-tiled I may help clear up some of the issues you are having without having to compromise performance. (though I think your problem is because you set "layer.fixedToCamera = false" if you remove that I think it will clear up the issue). Link to comment Share on other sites More sharing options...
mickez Posted December 2, 2014 Share Posted December 2, 2014 Hello! I've been struggling with this problem for quite a while, and finally solved it! What you got to do is use Canvas mode instead of WebGL mode, see issue here https://github.com/photonstorm/phaser/issues/1350 , supposedly fixed in the dev build. If you use canvas mode, you don't have to set "layer.fixedToCamera = false", and everything will hopefully work as expected! Link to comment Share on other sites More sharing options...
hellos3b Posted December 2, 2014 Author Share Posted December 2, 2014 Oh nice that did it! Although now my animations are wonky... time to figure out the cause of that edit: tinting is the cause of that Thanks mickez Link to comment Share on other sites More sharing options...
hellos3b Posted December 2, 2014 Author Share Posted December 2, 2014 Have you tried my plugin for phaser that makes rendering Tiled maps smoother? https://github.com/englercj/phaser-tiled I may help clear up some of the issues you are having without having to compromise performance. (though I think your problem is because you set "layer.fixedToCamera = false" if you remove that I think it will clear up the issue). I've glanced at it! One thing I'm planning on doing is having large areas which are like 6x6 large tilemaps stitched together that get dynamically loaded to make it seem seamless.. would your plugin make it easier for me to do that? Link to comment Share on other sites More sharing options...
xerver Posted December 3, 2014 Share Posted December 3, 2014 I've glanced at it! One thing I'm planning on doing is having large areas which are like 6x6 large tilemaps stitched together that get dynamically loaded to make it seem seamless.. would your plugin make it easier for me to do that? IMO, yes because a tilemap in my plugin isn't a special object is just a display object like any other so you can create a bunch of them and position the entire map easily. Link to comment Share on other sites More sharing options...
Recommended Posts