mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixed #38
This commit is contained in:
parent
7a59e175e0
commit
89c5e4a5d8
6 changed files with 64 additions and 25 deletions
|
|
@ -73,6 +73,7 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Notificat
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
} while (body = body.GetNext());
|
||||
|
||||
}
|
||||
|
|
@ -91,6 +92,14 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Notificat
|
|||
var player = this.players[playerId];
|
||||
player.spawn(x, y);
|
||||
this.gameObjects.animated.push(player.getDoll());
|
||||
|
||||
if(options.holdingItemUid) {
|
||||
this.onHandActionResponse({
|
||||
itemUid: options.holdingItemUid,
|
||||
action: "grab",
|
||||
playerId: playerId
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
GameController.prototype.onHandActionResponse = function(options) {
|
||||
|
|
@ -112,7 +121,7 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Notificat
|
|||
player.grab(item);
|
||||
}
|
||||
} else {
|
||||
console.warn("Item for joint can not be found locally.")
|
||||
console.warn("Item for joint can not be found locally. " + options.itemUid)
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,11 +14,6 @@ function (ProtocolHelper, GameController, User, NotificationCenter, Settings, Do
|
|||
this.gameController = null;
|
||||
this.users = {};
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
Networker.prototype.init = function () {
|
||||
|
||||
this.socketLink.on('connect', this.onConnect.bind(this));
|
||||
this.socketLink.on('disconnect', this.onDisconnect.bind(this));
|
||||
|
||||
|
|
@ -33,7 +28,6 @@ function (ProtocolHelper, GameController, User, NotificationCenter, Settings, Do
|
|||
NotificationCenter.on("sendGameCommand", this.sendGameCommand, this);
|
||||
}
|
||||
|
||||
|
||||
// Socket callbacks
|
||||
|
||||
Networker.prototype.onConnect = function () {
|
||||
|
|
@ -49,6 +43,10 @@ function (ProtocolHelper, GameController, User, NotificationCenter, Settings, Do
|
|||
}
|
||||
|
||||
Networker.prototype.onJoinSuccess = function (options) {
|
||||
NotificationCenter.on("game/level/loaded", function() {
|
||||
this.onLevelLoaded(options);
|
||||
}, this);
|
||||
|
||||
this.gameController = new GameController();
|
||||
this.gameController.loadLevel(options.levelUid);
|
||||
|
||||
|
|
@ -61,6 +59,10 @@ function (ProtocolHelper, GameController, User, NotificationCenter, Settings, Do
|
|||
}
|
||||
}
|
||||
|
||||
this.initPing();
|
||||
}
|
||||
|
||||
Networker.prototype.onLevelLoaded = function(options) {
|
||||
if (options.spawnedPlayers) {
|
||||
for(var i = 0; i < options.spawnedPlayers.length; i++) {
|
||||
this.gameController.onSpawnPlayer(options.spawnedPlayers[i]);
|
||||
|
|
@ -70,9 +72,7 @@ function (ProtocolHelper, GameController, User, NotificationCenter, Settings, Do
|
|||
if (options.worldUpdate) {
|
||||
this.gameController.onWorldUpdate(options.worldUpdate);
|
||||
}
|
||||
|
||||
this.initPing();
|
||||
}
|
||||
};
|
||||
|
||||
Networker.prototype.initPing = function() {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue