Lomaz Posted March 23, 2015 Share Posted March 23, 2015 Hello! kinda still new to phaser, had a quick question, I used tiled to create a map, i used 3 different layers: walls [unwalkable], zone1, and zone2, I can't seem to figure out how to tell where my sprite is.. as in if it's in zone1 or zone2, the zones are not simple rectangles, thus i can not figure out via simple calculations based on x/y positions, ideas? Thanks in advance! Link to comment Share on other sites More sharing options...
andreialex Posted March 23, 2015 Share Posted March 23, 2015 More information, or maybe a screen with some explanations? Link to comment Share on other sites More sharing options...
Lomaz Posted March 23, 2015 Author Share Posted March 23, 2015 http://imgur.com/wRWr9J8 Basiclly, I have a sprite on a map I generated with tiled, it has 3 layers: layer = map.createLayer('floor');layer2 = map.createLayer('walls');layer3 = map.createLayer('road'); Walls isn't walkable, and I want to identify at any given time if the sprite is over the 'floor' or 'walls' layer. I put a watch on the sprite, but don't see anything in it's information that dictates what layer it's on, only it's x/y location.. anything else I can tell you? Link to comment Share on other sites More sharing options...
andreialex Posted March 23, 2015 Share Posted March 23, 2015 I think you miss understood the layering.You don't need a layer for floor, walls and road, you can put them in one layer and name it background. You should at least download Tiled ( http://www.mapeditor.org/ ) and see how it works, you will understand better after that. Link to comment Share on other sites More sharing options...
Lomaz Posted March 23, 2015 Author Share Posted March 23, 2015 i used tiled to generate it, I understand what you are saying. So is there any way I can get the functionality I am aiming for? say I have a background layer and a walk-able layer, is there any way to differentiate WHERE the sprite is based not on x/y? Link to comment Share on other sites More sharing options...
valueerror Posted March 23, 2015 Share Posted March 23, 2015 map.getTileWorldXY(player.body.x, player.body.y,32,32, layerwalls) you can use this line to find out if there is a filled tile in an 32x32 area behind the player on the layerwalls Link to comment Share on other sites More sharing options...
andreialex Posted March 23, 2015 Share Posted March 23, 2015 What you can do is add another layer, which you can name it colision or whatever, where you add ones and zeros ( 1, 0)1 = walkable0 = not walkable This way you can set which tile is walkable and which is not regarding the terain you are on. Link to comment Share on other sites More sharing options...
Lomaz Posted March 24, 2015 Author Share Posted March 24, 2015 Thanks for the help both of you! I have managed to get the functionality using getTileWorldXY, works well enough I can use it! Link to comment Share on other sites More sharing options...
Recommended Posts