koobazaur Posted December 26, 2016 Share Posted December 26, 2016 Heya, I'm trying to implement a scene similar to Party Hard house where the wall tiles height is twice their width. When you walk from the bottom you stand in front of the wall, but when you walk from the top you go behind it. It's like walls in isometric games, but from a straight perspective. Is there any way to implement this using Tilemaps? It seems I'd need to create each wall as a separate object and just define collision to half the height, anchored to the bottom. I am also using TILED Map editor and don't think I can really do it inside it either (so I'd have to "fake" it in-game with higher wall tiles). I played with square tiles and adding a foreground layer to display the upper half of the walls BUT it only works presuming that the object sprites approaching from bottom are never tall enough to overlap the top half of the wall (otherwise it would be rendered in front). I want characters as tall as the walls and I want them to be able to walk pretty close from the bottom, so this approach doesn't work. Any ideas aside from creating each wall as a separate object and manually sorting depth based on the y coord of the wall / character sprite? Link to comment Share on other sites More sharing options...
koobazaur Posted December 28, 2016 Author Share Posted December 28, 2016 Bump - i take it there is no other solution then? Link to comment Share on other sites More sharing options...
drhayes Posted December 28, 2016 Share Posted December 28, 2016 There is, you can get Phaser to do it for you. You can sort your sprites by their y instead by calling Phaser.Group's sort method. From the docs: "For example to depth sort Sprites for Zelda-style game you might call group.sort('y', Phaser.Group.SORT_ASCENDING) at the bottom of your State.update()." Substitute whatever group you're using there (including the world, if that's where everything is being added). This all assumes that everything is in a single group, of course, which might not be what you want. Otherwise, yeah, you'll have to do it manually. Link to comment Share on other sites More sharing options...
koobazaur Posted December 28, 2016 Author Share Posted December 28, 2016 Oh neat thanks. Does it work on Tilemaps tho, treating each tile as a separate sprite and taking in other sprites in consideration? Hmm I don't think tiles/tilemaps even belong to a group though? Link to comment Share on other sites More sharing options...
drhayes Posted December 29, 2016 Share Posted December 29, 2016 You're correct. Each layer is kinda (kinda!) like its own sprite. If you want the player to walk behind things you might be better off using sprites that you could build from an object layer. Alternatively, you could layer things. First make the ground level layer, then add the player, then add the "everything about ground floor" layer. The first and third layers can come from your tilemap and be static. Because the player was added after the first layer, the player will appear in front of those graphics. But because the player was added before the third layer, the player will be behind that one -- which should achieve the effect you want. Link to comment Share on other sites More sharing options...
koobazaur Posted December 30, 2016 Author Share Posted December 30, 2016 Hmm not quite since i want the same wall (tile) to be either in front or behind, depending on where the player stands. Does phaser just create separate sprites for each tile? Or does it batch a layer into one big sprite? I thought it was more efficient than if i created the sprites for each tile myself. Reason I'm using it (and didn't want to create separate sprites for walls ) is for better performance. Link to comment Share on other sites More sharing options...
drhayes Posted December 30, 2016 Share Posted December 30, 2016 Not a sprite per tile, but a sprite per layer. You could combine the two approaches and have two layers and keep sorting when the player walks? I dunno. Link to comment Share on other sites More sharing options...
koobazaur Posted December 31, 2016 Author Share Posted December 31, 2016 Yea I thought about it, but I got other NPCs as well wandering so I dont want to limit them to not be able to walk too close too walls :/ Hmm guess creating individual wall sprites really is the only options Link to comment Share on other sites More sharing options...
drhayes Posted January 3, 2017 Share Posted January 3, 2017 When you figure it out, I'd love it if you came back and told us all how and what worked for your game. Link to comment Share on other sites More sharing options...
Recommended Posts