mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
implemented clientReady and changed loading of assets, fixed unique ragdoll id
This commit is contained in:
parent
f578b92734
commit
695008afd8
278 changed files with 306 additions and 287 deletions
58
client.js
58
client.js
|
|
@ -18,48 +18,18 @@ requirejs([
|
|||
|
||||
function (Networker, SocketIO, Settings, Exception, PIXI) {
|
||||
|
||||
function loadAssets(callback) {
|
||||
var url = "static/img/paths.txt";
|
||||
var loaded = document.getElementById("loaded");
|
||||
var loading = document.getElementById("loading");
|
||||
var count = 0;
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4) {
|
||||
if(xhr.status == 200) {
|
||||
var paths = xhr.responseText.split("\n");
|
||||
var max = paths.length;
|
||||
loader = new PIXI.AssetLoader(paths);
|
||||
loader.onComplete = function() { loading.style.display = "none"; callback(); };
|
||||
loader.onProgress = function() { loaded.style.width = (100 / max * ++count) + "%"; }
|
||||
loader.load();
|
||||
} else {
|
||||
throw new Exception("Assets preloader error: " + xhr.status + " " + xhr.statusText)
|
||||
}
|
||||
}
|
||||
}
|
||||
xhr.open("GET", url, true);
|
||||
xhr.send(null);
|
||||
//callback();
|
||||
}
|
||||
|
||||
loadAssets(function() {
|
||||
var options = {
|
||||
"reconnect": false,
|
||||
"reconnection delay": 500,
|
||||
"max reconnection attempts": 10,
|
||||
|
||||
"transports": [
|
||||
"websocket",
|
||||
"flashsocket"
|
||||
],
|
||||
};
|
||||
var socket = SocketIO.connect(location.href, options);
|
||||
var networker = new Networker(socket);
|
||||
inspector.networker = networker;
|
||||
inspector.settings = Settings;
|
||||
inspector.resetLevel = function() { networker.sendGameCommand("resetLevel"); }
|
||||
});
|
||||
|
||||
var options = {
|
||||
"reconnect": false,
|
||||
"reconnection delay": 500,
|
||||
"max reconnection attempts": 10,
|
||||
"transports": [
|
||||
"websocket",
|
||||
"flashsocket"
|
||||
]
|
||||
};
|
||||
var socket = SocketIO.connect(location.href, options);
|
||||
var networker = new Networker(socket);
|
||||
inspector.networker = networker;
|
||||
inspector.settings = Settings;
|
||||
inspector.resetLevel = function() { networker.sendGameCommand("resetLevel"); }
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue