aylictal Posted April 14, 2018 Share Posted April 14, 2018 Hello again- I'm looking for an efficient way to render top down view based upon json data from entities. I have it working, as well as working with multiple layers, but now comes the difficult part. Say I have a call such as: this.map = this.make.tilemap({key: 'map'}); this.tileset = this.map.addTilesetImage('backgroundtiles'); this.layer = this.map.createStaticLayer('Tile Layer 1', this.tileset, 0, 0); this.layer2 = this.map.createStaticLayer('Tile Layer 2', this.tileset, 0, 0); This works, and it works beautifully. It renders the different layers and places them all effectively in the background. Now the problem is that layer2 is a layer of trees, with varying individual tiles composing them (some are 4 tiles high, some are 3 tiles high, etc). The player then runs around the map but the trees are always displaying behind him in render order, which is fine if the player is below (y position is greater than the y position of the respective tree). What I need the engine to do though is to render the tree in front of the player if the players y position is less than the y position of the tree, but I have no idea if it's even possible to get the actual tree y position. Is there any efficient way to render the trees in front of the player if the players y position is less than the respective tree in consideration? What is a good way to approach this problem when I desperately don't want to programmatically create the trees, but use the tree data from the json from Tiled? Is this possible? Thanks again, you guys rock! Link to comment Share on other sites More sharing options...
Secretmapper Posted April 14, 2018 Share Posted April 14, 2018 This would be awesome as I feel a lot of top down games need this feature. I'm not sure if this is in Phaser 3 but I would imagine this could (might?) be supported in dynamicTile Link to comment Share on other sites More sharing options...
aylictal Posted April 18, 2018 Author Share Posted April 18, 2018 What is dynamicTile @Secretmapper ? I've been thinking of ways around this all week but to no avail I'm not sure what I can do other than hardcode the trees themselves as individual sprites. Link to comment Share on other sites More sharing options...
Secretmapper Posted April 20, 2018 Share Posted April 20, 2018 Hey @aylictal Dynamic Tile Layer is basically static layer with more features (like tint/alpha of individual sprites) https://photonstorm.github.io/phaser3-docs/Phaser.Tilemaps.DynamicTilemapLayer.html It seems like there's currently no support for this feature (dynamic tile depth) so sprites seems to be the only way right now. Hopefully it will be added in the future. Link to comment Share on other sites More sharing options...
Recommended Posts