Last active
November 13, 2015 02:42
-
-
Save trentbrooks/a99230cf4637b86cce98 to your computer and use it in GitHub Desktop.
C++11 lambda + std::function callbacks. eg. sequence of animations
This file contains 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
// https://msdn.microsoft.com/en-us/library/dd293599.aspx & https://msdn.microsoft.com/en-us/library/dd293608.aspx | |
// sequence of tweens/animations called sequentially | |
tween.go(&width, 200, 1.0).onDone([&]() { | |
tween.go(&height, 100, 1.0).onDone([&]() { | |
tween.go(&target, ofVec3f(100,200), 1.0).onDone([&]() { | |
tween.go(&target, ofVec3f(800,400), 3.0).onDone([&]() { | |
tween.go(&rotation, 900, 1.0).onDone([&]() { | |
tween.go(&target, ofVec3f(ofGetWidth()/2, ofGetHeight()/2), 2.0); | |
}); | |
}); | |
}); | |
}); | |
}); |
This file contains 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
// min example of tween class callback property + onDone() method... | |
function<void(void)> callback; | |
void onDone(function<void(void)> lambda) { | |
callback = lambda; // can now fire callback() when tween is finished | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment