fix ship respawning

This commit is contained in:
Asraelite 2016-03-30 20:48:06 +01:00
parent 8e0c4b02e4
commit 79dd88fd67
2 changed files with 12 additions and 3 deletions

View file

@ -21,11 +21,12 @@ class Net {
});
this.socket.on('world', data => {
game.world.clear();
window.q = data;
game.world.bounds = data.bounds;
game.player.inputInterface = data.inputInterface;
for (var b of data.bodies) {
game.world.add(b);
if (data.bodies) {
game.world.clear();
data.bodies.forEach(b => game.world.add(b));
}
game.world.setPlayerShip(data.playerShipId);
});

View file

@ -29,6 +29,14 @@ class Spawner {
let ship = new Ship(this.world, pos, player);
player.ship = ship;
this.world.addShip(ship);
let data = {
playerShipId: player.ship.id,
inputInterface: player.inputInterface,
bounds: this.world.bounds,
};
player.sendWorld(data);
}
spawnMissile(ship) {