Josh Engebretson 11 years ago
parent
commit
25f6f96fdb

+ 7 - 3
PhysicsPlatformer/Resources/Components/Avatar.js

@@ -35,8 +35,8 @@ circle.setRestitution(0.1);
 
 var anim = "Idle";
 var flipped = false;
-
 var contactCount = 0;
+var jumpDelta = 0;
 
 self.onPhysicsBeginContact2D = function(world, bodyA, bodyB, nodeA, nodeB) {
 
@@ -124,6 +124,8 @@ function handleInput(timeStep) {
 
     var vel = body.linearVelocity;
     var pos = node.position2D;
+    
+    jumpDelta  -= timeStep;
 
     if (Math.abs(vel[0]) > MAX_VELOCITY) {
         vel[0] = (vel[0] ? vel[0] < 0 ? -1 : 1 : 0) * MAX_VELOCITY;
@@ -182,13 +184,15 @@ function handleInput(timeStep) {
     if (!contactCount)
         circle.friction = 0.0;
 
-    if (jump && contactCount) {
+    if (jump && jumpDelta <= 0 && contactCount) {
+        
+        jumpDelta = .25;
         self.soundSource.gain = 0.75;
         self.soundSource.play(jumpSound);
 
         vel[1] = 0;
         body.linearVelocity = vel;
-        body.applyLinearImpulse([0, 3], pos, true);
+        body.applyLinearImpulse([0, 6], pos, true);
     }
 
 }

+ 7 - 0
PhysicsPlatformer/Resources/Components/Fire.js

@@ -0,0 +1,7 @@
+
+
+var node = self.node;
+
+node.scale2D = [.2, .2];
+var fire = node.createComponent("ParticleEmitter2D");
+fire.setEffect(cache.getResource("ParticleEffect2D", "Particles/fire.pex"));

+ 16 - 0
PhysicsPlatformer/Resources/Components/Level.js

@@ -31,6 +31,7 @@ self.batWaypoints = [];
 var coins = [];
 var bats = [];
 var vines = [];
+var fires = [];
 
 var beginContactCallbacks = {};
 
@@ -84,6 +85,12 @@ function createVine(obj) {
     vineNode.createJSComponent("Vine");
 }
 
+function createFire(obj) {
+
+    var vineNode = scene.createChild("Fire");
+    vineNode.position2D = obj.position;
+    vineNode.createJSComponent("Fire");
+}
 
 function parseEntities() {
 
@@ -128,6 +135,10 @@ function parseEntities() {
 
                 vines.push(o);
 
+            } else if (o.type == "Fire") {
+
+                fires.push(o);
+
             }
 
 
@@ -156,6 +167,11 @@ function parseEntities() {
         createVine(vines[i]);
 
     }
+    for (var i in fires) {
+
+        createFire(fires[i]);
+
+    }
 
 }
 

+ 0 - 2
PhysicsPlatformer/Resources/Components/Vine.js

@@ -8,8 +8,6 @@ var x = node.position2D[0];
 var y = node.position2D[1];
 node.position = [0, 0, 0];
 
-print("VINE!");
-
 function start() {
 
     // create the node body

BIN
PhysicsPlatformer/Resources/UI/UI_HEART_FULL.png