Jump to content

Wall tiles you can walk behind (2x1)?


koobazaur
 Share

Recommended Posts

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

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

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

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

 Share

  • Recently Browsing   0 members

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