Raikoh Posted April 15, 2014 Share Posted April 15, 2014 I have a tilemap with all tiles set to alpha = 0, when my character come close to a tile it becomes visible. The issue is that the tiles seem to update only when my camera moves. Like when the camera needs to scroll to follow the character all is ok, but when the camera doesn't have to move if my character is close to the edge the tiles stay invisible until the camera move. this is in my create function: this.map = this.game.add.tilemap('tilemap'); this.map.addTilesetImage('pixel', 'pixel'); this.layer1 = this.map.createLayer('layer1'); this.layer1.resizeWorld(); this.map.setCollision(1); this.sprite = this.add.sprite(50, 50, 'sheep'); this.game.physics.enable(this.sprite); this.game.camera.follow(this.sprite); var tiles = this.layer1.getTiles(0, 0, 2961, 2961); //I set all the tiles to alpha(0); for (var i = 0; i < tiles.length; i++) { tiles.alpha = 0; and this in the update: var tiles = this.layer1.getTiles(this.sprite.body.x - 20 , this.sprite.body.y - 20 , 80, 80);//I get all the tiles close to me and make them visible for (var i = 0; i < tiles.length; i++) { tiles.alpha = 1; } So this would work fine if the camera were always moving when the character does, but i think phaser don't look at the tiles when the camera isn't moving (since it doesn't need to in normal use of tiles).I tried to see if i could force the update of tiles at every loop but didn't find anything, could use some help, thx.ps: i use typescript. Link to comment Share on other sites More sharing options...
rich Posted April 15, 2014 Share Posted April 15, 2014 Try setting the layer.dirty value to 'true' when a tile alpha changes - does that work? Raikoh and grinmonk 2 Link to comment Share on other sites More sharing options...
Raikoh Posted April 15, 2014 Author Share Posted April 15, 2014 Wow thx man, you are so good and quick , looks awesome now ! Link to comment Share on other sites More sharing options...
rich Posted April 15, 2014 Share Posted April 15, 2014 I'll take that as a "yes it worked" then Link to comment Share on other sites More sharing options...
Raikoh Posted April 15, 2014 Author Share Posted April 15, 2014 yeah it does work great, dirty is a weird name for controlling re-render tho, but now that im aware of it, i will read every single description before asking Link to comment Share on other sites More sharing options...
Recommended Posts