Ashish Posted July 27, 2016 Share Posted July 27, 2016 I am trying to create a game where I have created one player and at the background I have added tiled map. The problem is how can I get the player coordinate every time so that I can replace the tiles covered by the player. Thank you ! Link to comment Share on other sites More sharing options...
Ralph Posted July 28, 2016 Share Posted July 28, 2016 Could you please elaborate a little more? Any more information or just make your first post make more sense please lol What I kind of got from that is that you have a player and a tiled map ABOVE the player, and you want the players tiled coordinates so you can remove the tile ABOVE the player (so you can see the player). I might be wrong to what you mean bc idrk what you were trying to say in the post above. But, if that is what you were trying to say, there is no need to do that since you can just move the player sprite to show up above the tiled layer. If you are having the problem i described, you most likely defiened the tiled layer after you defined the sprite? If that wasnt your problem and want to just find out what tiled coordinate the player is at, you can do something like this: tiledX = Math.round(player.x/(the width of a tile in your tiled map)); tiledY = Math.round(player.y/(the height of a tile in your tiled map)); Ashish 1 Link to comment Share on other sites More sharing options...
Recommended Posts