Jerenaux / phaserquest

Reproduction of Mozilla's BrowserQuest using Phaser, socket.io and Node.js
http://www.dynetisgames.com/2017/03/18/phaser-quest/
MIT License
371 stars 127 forks source link

Client server sync fix #2

Closed Kaundur closed 7 years ago

Kaundur commented 7 years ago

Fast clicking causes the client and server to go out of sync.

For example, clicking a destination multiple times a second causes the player to move server side, however the player client side is reset to its starting position and attempts to move to the destination again. The reset command doesn't act fast enough for the players position to be corrected before the next click event comes in

I've applied a 0.2s click delay to the code, which gives the reset command time to fix the players position when things go out of sync