Maharl Posted December 20, 2017 Share Posted December 20, 2017 Code pen: I am moving a NPC back and forth on a plattform by checking if the end tile is one of the tiles that are edges in the tilemap and if so swicthing the x velocity. I am having trouble with getting the moving sprite to move equally as far out of the edge of the plattform on both sides, but it seems the sprite is only colliding with one tile at the time, namely the tile that is touching the right bottom corder of the sprite, can I set the collide to be on the tile that is under the middle of the sprite? Link to comment Share on other sites More sharing options...
samme Posted December 21, 2017 Share Posted December 21, 2017 It's because the tiles are checked for collisions from left to right, and after the sprite is separated (vertically) from the left tile, it's no longer contacting the right. Link to comment Share on other sites More sharing options...
Maharl Posted December 21, 2017 Author Share Posted December 21, 2017 What is the best way to the result I want? Link to comment Share on other sites More sharing options...
samme Posted December 21, 2017 Share Posted December 21, 2017 This seems to work: Link to comment Share on other sites More sharing options...
Maharl Posted December 25, 2017 Author Share Posted December 25, 2017 Thank you so much, this was a great Christmas present ? Link to comment Share on other sites More sharing options...
Maharl Posted May 1, 2018 Author Share Posted May 1, 2018 Anyone know how to do this in Phaser 3? Link to comment Share on other sites More sharing options...
samme Posted May 1, 2018 Share Posted May 1, 2018 I think the collide/overlap callbacks work the same in Phaser 3. I don't know if the Tile object (e.g., tile.index) is the same though. Link to comment Share on other sites More sharing options...
Recommended Posts