This commit is contained in:
Jeena 2014-02-10 16:11:01 +01:00
parent 7a59e175e0
commit 89c5e4a5d8
6 changed files with 64 additions and 25 deletions

View file

@ -1,10 +1,11 @@
define([
"Game/" + GLOBALS.context + "/Physics/Engine",
"Game/" + GLOBALS.context + "/Loader/TiledLevel",
"Game/" + GLOBALS.context + "/Player"
"Game/" + GLOBALS.context + "/Player",
"Lib/Utilities/NotificationCenter"
],
function (PhysicsEngine, TiledLevel, Player) {
function (PhysicsEngine, TiledLevel, Player, NotificationCenter) {
function GameController () {
this.players = {};
@ -17,7 +18,7 @@ function (PhysicsEngine, TiledLevel, Player) {
this.physicsEngine = new PhysicsEngine();
this.physicsEngine.setCollisionDetector();
this.update();
NotificationCenter.on("game/level/loaded", this.onLevelLoaded, this);
}
GameController.prototype.update = function() {
@ -45,6 +46,10 @@ function (PhysicsEngine, TiledLevel, Player) {
this.loadLevel(this.level.uid);
};
GameController.prototype.onLevelLoaded = function() {
this.update();
};
GameController.prototype.destroy = function () {
for(var player in this.players) {