Bläddra i källkod

Fix update issue

Josh Engebretson 10 år sedan
förälder
incheckning
86279b913f

+ 5 - 4
PhysicsPlatformer/Resources/Components/Level.js

@@ -11,9 +11,6 @@ self.init = function(level) {
     self.tileMap.setTmxFile(self.tmxFile);
     self.levelParser = new LevelParser(self.tileMap);
     
-    var backgroundNode = scene.createChild("Background");
-    backgroundNode.createJSComponent("Background");
-
 }
 
 function spawnPlayer() {
@@ -23,7 +20,11 @@ function spawnPlayer() {
     self.playerNode = node.createChild("PlayerNode");
     self.player = self.playerNode.createJSComponent("Player");
     self.player.init(position);
-
+    
+    // Create the background after the player as it's position is updated
+    // after the player in post update
+    var backgroundNode = scene.createChild("Background");
+    backgroundNode.createJSComponent("Background");
 }
 
 function createEntities() {

+ 1 - 2
PhysicsPlatformer/Resources/Components/Lighting.js

@@ -8,8 +8,7 @@ var node = self.node;
 var daytime = Platformer.daytime;
 
 function start() {
-
-    // currently lightgroup must be created after viewport 0 is set
+    
     var lightGroup = node.createComponent("Light2DGroup");    
     lightGroup.setPhysicsWorld(Platformer.physicsWorld);
     Platformer.lightGroup = lightGroup;