code herd Posted December 3, 2013 Share Posted December 3, 2013 Hi, I've just started messing around with Phaser, and I have to say it's pretty awesome! great work on it! I have a question though. I've looked around in the docs and examples but there doesn't seem to be anything that I can see for moving a sprite to a certain tile on a tilemap. So for example I have the tilemap coordinates (5,9) and I want to move the sprite to the screen coordinates for that tile. Is there something there for getting them? or maybe moving it to the object or something, that I'm missing? Thanks in advance Link to comment Share on other sites More sharing options...
rich Posted December 3, 2013 Share Posted December 3, 2013 Wrap this up in a function you can re-use, but basically:sprite.x = this.game.math.snapToFloor(x, tileWidth) / tileWidth;sprite.y = this.game.math.snapToFloor(y, tileHeight) / tileHeight;Where x and y in your case are 5,9. Link to comment Share on other sites More sharing options...
Recommended Posts