Created
October 10, 2015 19:57
-
-
Save joseph-montanez/da67ac6f44cbf325a2e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var node = parentNode.addChild(); | |
function nextTrans(trans) { | |
var scale = [1,1,1]; | |
if (node.getScale()[0] == 1) { | |
scale = [0.2, 0.2, 0.2]; | |
} | |
trans.to([Math.random() * 10, Math.random() * 10, scale[0], scale[1], scale[2]], 'inOutQuad', 1500, function () { | |
nextTrans(trans); | |
}); | |
} | |
var pos = node.getPosition(); | |
var trans = new Transitionable().from([pos[0],pos[1],pos[2],1,1,1]); | |
nextTrans(trans); | |
var zoomInOutComp = node.addComponent({ | |
onUpdate: function (time) { | |
if (_SceneTwo.paused) { | |
//-- The scene us paused | |
trans.pause(); | |
} else { | |
//-- The scene is not pause | |
if (trans.isPaused()) { | |
//-- the scene was unpaused, so we should | |
trans.resume(); | |
} | |
var params = trans.get(); | |
node.setPosition(params[0], params[1], params[2]); | |
node.setScale(params[3], params[4], params[5]); | |
} | |
if (trans.isActive()) { | |
//-- As long as the Transitional is active, keep updating | |
node.requestUpdate(this); | |
} | |
} | |
}); | |
// Let the magic begin... | |
node.requestUpdate(zoomInOutComp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment