Jump to content

Name following the player with delay


Heron
 Share

Recommended Posts

Same problem: 

Your problem is in Game.js:

if(game.player.deltaX !== 0 || game.player.deltaY !== 0){
    game.player.name.x = game.player.x;
    game.player.name.y = game.player.y - 50;
    this.socket.emit("movePlayer", {x: game.player.x, y: game.player.y});
}

You should not be moving objects around by manually setting the x/y values in this situation. You should attach the name to the player as a child. In player.js, add player.addChild(player.name); after creating the name text object.

Also, I wouldn't recommend generating your player ID on the client. Make it on the server when the client connects then send it to them.

var PlayerID = Math.floor(Math.random() * (999999 - 100000 + 1)) + 100000;

Just looks wrong...

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...