From 789f3231e10dbe705e20996dcf88dc9110630e83 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 9 Nov 2015 19:18:19 -0800 Subject: [PATCH] easier bouncing --- examples/libraries/easyStarExample.js | 32 ++++++++++++--------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/examples/libraries/easyStarExample.js b/examples/libraries/easyStarExample.js index c4368f8ff8..20a50d2f7d 100644 --- a/examples/libraries/easyStarExample.js +++ b/examples/libraries/easyStarExample.js @@ -29,7 +29,6 @@ var grid = [ ]; - easystar.setGrid(grid); easystar.setAcceptableTiles([0]); @@ -40,6 +39,7 @@ easystar.findPath(0, 0, 8, 0, function(path) { Script.update.disconnect(tickEasyStar); } else { print('path' + JSON.stringify(path)); + convertPath(path); Script.update.disconnect(tickEasyStar); } @@ -79,6 +79,16 @@ var playerSphere = Entities.addEntity({ linearDamping: 0.2 }); +Script.setInterval(function(){ + Entities.editEntity(playerSphere,{ + velocity:{ + x:0, + y:4, + z:0 + } + }) +},1000) + var sphereProperties; //for keeping track of entities @@ -187,12 +197,8 @@ function updatePosition() { x: currentSpherePosition.z, y: sphereProperties.position.y, z: currentSpherePosition.x - }, - velocity: { - x: 0, - y: velocityShaper.y, - z: 0 } + }); } @@ -227,19 +233,9 @@ function createTweenPath(convertedPath) { stepTweens[j].chain(stepTweens[j + 1]); } - - var velocityUpTween = new TWEEN.Tween(velocityShaper).to(upVelocity, ANIMATION_DURATION).onUpdate(updatePosition); - var velocityDownTween = new TWEEN.Tween(velocityShaper).to(noVelocity, ANIMATION_DURATION).onUpdate(updatePosition); - - velocityUpTween.chain(velocityDownTween); - velocityDownTween.chain(velocityUpTween); - - - velocityUpTween.easing(TWEEN.Easing.Linear.None) - velocityDownTween.easing(TWEEN.Easing.Back.InOut) - //start the tween + //start the tween stepTweens[0].start(); - velocityUpTween.start(); + } var velocityShaper = {