Jump to content

sprite position detection


Lomaz
 Share

Recommended Posts

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

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

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

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 = walkable

0 = 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

 Share

  • Recently Browsing   0 members

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