Jump to content

Collision of tilemap layer not moving with offset?


DanielP565
 Share

Recommended Posts

I'm trying to offset tilemaps for each room I have and the collision doesn't seem to go with it. Link to game: here

You can see the collision overlaps eachother on the first tilemap and there is no collision on the second one.

 

	createMap: function() {
	    this.layers = {};
	    this.map = this.game.add.tilemap('east');
		this.map.addTilesetImage('dungeon_tiles', 'tiles');
		var rnd = 1;
		console.log("rolled a ", rnd);
		
        this.map.layers.forEach(function (layer) {
            this.layers[layer.name] = this.map.createLayer(layer.name);
            this.layers[layer.name].fixedToCamera = false;
            if(layer.properties.collision) {
                this.map.setCollision(291, true, layer.name);
                collision = this.map.getLayer(layer).name;
            }
            
            if(layer.properties.ignore) {
                return;
            } else if(layer.properties.group == rnd) {
                this.layers[layer.name].visible = true;
            } else {
                this.layers[layer.name].visible = false;
            }
        }, this);
        
        this.layers2 = {};
        this.map2 = this.game.add.tilemap('map');
		this.map2.addTilesetImage('dungeon_tiles', 'tiles');
		 this.map2.layers.forEach(function (layer) {
            this.layers2[layer.name] = this.map2.createLayer(layer.name);
            this.layers2[layer.name].fixedToCamera = false;
            this.layers2[layer.name].position.set(256, 0);
            if(layer.properties.collision) {
                this.map2.setCollision(291, true, layer.name);
                collision2 = this.map2.getLayer(layer).name;
            }
        }, this);
        
        this.layers[collision].debug = true;
        this.layers2[collision2].debug = true;
	},

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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