fojik Posted July 7, 2015 Share Posted July 7, 2015 Hello, I have a problem with the movement of the character Client MouseClick executed: movePlayer: function(pointer) { this.mouseTargetX = pointer.worldX; this.mouseTargetY = pointer.worldY; if(hero.x == this.mouseTargetX && hero.y == this.mouseTargetY) return; net.sock.send(toJSON('@w', {x:pointer.worldX,y:pointer.worldY})); player.rotation = this.game.physics.arcade.angleToPointer(player, pointer); },Server NodeJS:exports.playerMove = function(xy){ var duration = (distanceToXY({x:player.x,y:player.y}, xy.x, xy.y) / 65) * 1000; var distance = distanceToXY({x:player.x,y:player.y}, xy.x, xy.y); player.x = xy.x; player.y = xy.y; if(distance < 1400) { res = global.toJSON('@w', {x:player.x, y:player.y, d:duration}); global.s.write(res); global.con.update('profiles',{x:player.x, y:player.y},{id:player.id}, function(err, affectedRows) { console.log(err); console.log(affectedRows) }); }}Again, the clientmove:function(data) { if (tween && tween.isRunning) { tween.stop(); } this.x = data.x; this.y = data.y; tween = game.add.tween(player).to({ x:data.x, y: data.y }, data.d, Phaser.Easing.Linear.None, true); }But if you press many times click, the character is teleported to the point How to check the movement of the player?If he did not finish the movement (updated page) to stop the execution of the on-site break Link to comment Share on other sites More sharing options...
Recommended Posts