mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
Makes world in Engine private
And some refactoring.
This commit is contained in:
parent
8641a2dc0b
commit
c068592915
3 changed files with 12 additions and 14 deletions
|
|
@ -14,7 +14,7 @@ function (Box2D, Exception, Assert, Nc) {
|
||||||
|
|
||||||
var def = this.getBodyDef();
|
var def = this.getBodyDef();
|
||||||
def.userData = this;
|
def.userData = this;
|
||||||
this.body = physicsEngine.getWorld().CreateBody(def);
|
this.body = physicsEngine.createBody(def);
|
||||||
|
|
||||||
this.ncTokens = (this.ncTokens || []).concat([
|
this.ncTokens = (this.ncTokens || []).concat([
|
||||||
Nc.on(Nc.ns.client.game.events.destroy, this.destroy, this)
|
Nc.on(Nc.ns.client.game.events.destroy, this.destroy, this)
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ define([
|
||||||
|
|
||||||
Level.prototype.load = function (uid) {
|
Level.prototype.load = function (uid) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
// FIXME: check if theres a security hazard here (user injected path)
|
||||||
var path = Settings.MAPS_PATH + uid + ".json";
|
var path = Settings.MAPS_PATH + uid + ".json";
|
||||||
this.loadLevelDataFromPath(path, function (levelData) {
|
this.loadLevelDataFromPath(path, function (levelData) {
|
||||||
self.setup(levelData);
|
self.setup(levelData);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ function (Settings, Box2D, CollisionDetector, Nc) {
|
||||||
Settings.BOX2D_ALLOW_SLEEP
|
Settings.BOX2D_ALLOW_SLEEP
|
||||||
);
|
);
|
||||||
this.world.SetWarmStarting(true);
|
this.world.SetWarmStarting(true);
|
||||||
this.ground = null;
|
|
||||||
this.lastStep = Date.now();
|
this.lastStep = Date.now();
|
||||||
this.worldQueue = [];
|
this.worldQueue = [];
|
||||||
|
|
||||||
|
|
@ -24,24 +23,22 @@ function (Settings, Box2D, CollisionDetector, Nc) {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine.prototype.getWorld = function () {
|
|
||||||
return this.world;
|
|
||||||
}
|
|
||||||
|
|
||||||
Engine.prototype.getGround = function () {
|
|
||||||
return this.ground;
|
|
||||||
}
|
|
||||||
|
|
||||||
Engine.prototype.setCollisionDetector = function () {
|
Engine.prototype.setCollisionDetector = function () {
|
||||||
|
|
||||||
var detector = new CollisionDetector();
|
var detector = new CollisionDetector();
|
||||||
this.world.SetContactListener(detector.getListener());
|
this.world.SetContactListener(detector.getListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Engine.prototype.getWorldForRubeLoader = function() {
|
||||||
|
return this.world;
|
||||||
|
};
|
||||||
|
|
||||||
Engine.prototype.createBody = function (bodyDef) {
|
Engine.prototype.createBody = function (bodyDef) {
|
||||||
var body = this.world.CreateBody(bodyDef);
|
return this.world.CreateBody(bodyDef);
|
||||||
if(!this.ground) this.ground = body;
|
}
|
||||||
return body;
|
|
||||||
|
Engine.prototype.destroyBody = function (body) {
|
||||||
|
return this.world.DestroyBody(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine.prototype.addToWorldQueue = function(callback) {
|
Engine.prototype.addToWorldQueue = function(callback) {
|
||||||
|
|
@ -65,8 +62,8 @@ function (Settings, Box2D, CollisionDetector, Nc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine.prototype.destroy = function() {
|
Engine.prototype.destroy = function() {
|
||||||
delete this.world;
|
|
||||||
Nc.offAll(this.ncTokens);
|
Nc.offAll(this.ncTokens);
|
||||||
|
delete this.world;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue