Jump to content

Large TileMap only creating viewport size


hellos3b
 Share

Recommended Posts

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 world

define(['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

 

IwdWIAQ.png (Left is game, right is in Tiled)

 

Am I missing something?

Link to comment
Share on other sites

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

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

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

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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...