Jump to content

Animating other players


divers
 Share

Recommended Posts

Hello, I am creating realtime game using node + socket.io.

At the moment I'm trying to figure out how could I animate other players movements.

This is how I put other players on map:

	socket.on('showPlayers', (data) => {
		for (var key in data.players) {
			if(key != data.id)
				players[key] = game.add.sprite(data.players[key].position.x, data.players[key].position.y, 'player', 1);
        }		
    });

And Updating their positions:

	socket.on('updatePlayers', (data) => {
		players[data.id].position = data.position;
    });

To animate my own player I am simply using:

    //  Player
    player = game.add.sprite(48, 48, 'player', 1);
    player.animations.add('left', [3,5], 5, true);
    player.animations.add('right', [6,8], 5, true);
    player.animations.add('up', [9,11], 5, true);
    player.animations.add('down', [0,2], 5, true);

 

Best Regards!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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