mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
fixed problem when user disconnected
This commit is contained in:
parent
e751210345
commit
7d0df79ac8
8 changed files with 73 additions and 33 deletions
|
|
@ -2,20 +2,28 @@ define(["Chuck/Processors/ClientProcessor"], function(ClientProcessor) {
|
|||
|
||||
function ClientGame(networker, id) {
|
||||
this.networker = networker;
|
||||
this.processor = new ClientProcessor(this);
|
||||
this.processor.spawnMeWithId(id);
|
||||
this.clientProcessor = new ClientProcessor(this);
|
||||
this.clientProcessor.spawnMeWithId(id);
|
||||
|
||||
this.players = {};
|
||||
}
|
||||
|
||||
ClientGame.prototype.loadLevel = function(path) {
|
||||
this.processor.loadLevel(path);
|
||||
this.clientProcessor.loadLevel(path);
|
||||
}
|
||||
|
||||
ClientGame.prototype.userJoined = function(userId) {
|
||||
this.processor.spawnNewPlayerWithId(userId);
|
||||
};
|
||||
this.players[userId] = this.clientProcessor.spawnNewPlayerWithId(userId);
|
||||
}
|
||||
|
||||
ClientGame.prototype.userLeft = function(userId) {
|
||||
var player = this.players[userId];
|
||||
player.destroy();
|
||||
delete this.players[userId];
|
||||
}
|
||||
|
||||
ClientGame.prototype.processGameCommand = function(command, options){
|
||||
this.processor.processGameCommand(command, options);
|
||||
this.clientProcessor.processGameCommand(command, options);
|
||||
}
|
||||
|
||||
ClientGame.prototype.sendGameCommand = function(command, options) {
|
||||
|
|
@ -23,7 +31,7 @@ define(["Chuck/Processors/ClientProcessor"], function(ClientProcessor) {
|
|||
}
|
||||
|
||||
ClientGame.prototype.destruct = function(){
|
||||
this.processor.destruct();
|
||||
this.clientProcessor.destruct();
|
||||
}
|
||||
|
||||
return ClientGame;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue