-
Notifications
You must be signed in to change notification settings - Fork 126
7. A Note on Reuse
Michael Carriere edited this page Jul 28, 2014
·
3 revisions
Almost any of GoKit's objects were designed to be reused allowing you to keep your code clean and avoiding allocations whenever possible. The most common object with regard to reuse is the GoTweenConfig object. You can setup all of your GoTweenProperties on a GoTweenConfig instance then apply it to as many target objects as you want. You can even make some changes in between uses to customize the Tween. Below is an example of reusing a GoTweenConfig to perform two similar tweens on two different target objects.
// setup a scale tween property that iterates 3 times
var config = new GoTweenConfig().scale( 3 ).setIterations( 3 );
// add it to the first Transform
Go.to( someTransform, 3f, config );
// make some changes to the config (delay it 3 seconds, add a material color property and reduce the
// iteration count to 1) to customize the second Tween
config.setDelay( 3f ).materialColor( Color.black ).setIterations( 1 );
// add it to the second Transform
Go.to( otherTransform, 2f, config );