Skip to content

Instantly share code, notes, and snippets.

@joseph-montanez
Created October 10, 2015 19:57
Show Gist options
  • Save joseph-montanez/da67ac6f44cbf325a2e4 to your computer and use it in GitHub Desktop.
Save joseph-montanez/da67ac6f44cbf325a2e4 to your computer and use it in GitHub Desktop.
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