@@ -29,17 +29,55 @@ handler.Update(200); // point.X == 4
2929handler .Update (200 ); // point.X == 6
3030handler .Update (200 ); // point.X == 8
3131handler .Update (200 ); // point.X == 10
32- handler .Update (100 ); // point.X == 10 (Tween has ended)
32+ handler .Update (100 ); // point.X == 10 (tween has ended)
3333```
34- Ideally you create own handler instance and update it everytime your scene renders.
34+ Ideally you create one handler instance and update it everytime your scene renders. For example for WPF the CompositionTarget.Rendering event .
3535
3636### Fine tuning
3737You can use easing functions, delays and concatination of multiple properties.
3838``` C#
39- point .Tween (x => x .X ).And (x => x .Y ).To (20 ).In (1 . 5 ).Ease (Easing .BackEaseIn ).Delay (0 . 5 );
39+ point .Tween (x => x .X )
40+ .And (x => x .Y ) // tween multiple properties at once
41+ .To (20 ).In (1 . 5 )
42+ .Ease (Easing .BackEaseIn ) // specify custom easing functions
43+ .Delay (0 . 5 ); // specify a delay before the tweening starts
4044 ````
4145See the Easing .cs class for all available easing methods.
4246
47+ ### Sequence
48+ Use .ToSequence() to nest multiple tweens into one
49+ ```C#
50+ var tweens = new List<Timeline >(); // timeline is the base class for tweens
51+ tweens .Add (point .Tween (x => x .X ).To (20 ).In (1 ));
52+ tweens .Add (point .Tween (x => x .Y ).To (10 ).In (1 ));
53+ handler .Add (tweens .ToSequence ()); // a sequence is a single instance which contains multiple tweens
54+ ````
55+
56+ ### AlwaysOnCurrentValue
57+ React to interrupting value changes .
58+ AlwaysOnCurrentValue tells the tween to always use the current value instead of initializing it once the tweens starts .
59+ ```C #
60+ // with AlwaysOnCurrentValue = false (default)
61+ handler .Add (point .Tween (x => x .X ).To (10 ).In (0 . 5 ));
62+ handler .Update (100 ); // point.X == 2, initialized start value with the current value of point.X (0)
63+ handler .Update (100 ); // point.X == 4
64+ handler .Update (100 ); // point.X == 6
65+ point .X = 0 ;
66+ // the current value is calculated with the progress (80%) of the start value (0) and target value (10):
67+ handler .Update (100 ); // point.X == 8 // note that updating point.X did not have an effect on the tween
68+ handler .Update (100 ); // point.X == 10
69+
70+ // with AlwaysOnCurrentValue = true
71+ handler .Add (point .Tween (x => x .X ).To (10 ).In (0 . 5 ).AlwaysOnCurrentValue (false ));
72+ handler .Update (100 ); // point.X == 2
73+ handler .Update (100 ); // point.X == 4
74+ handler .Update (100 ); // point.X == 6
75+ point .X = 0 ;
76+ // the current value is calculated with the progress (80%) of the CURRENT value (0) and target value (10):
77+ handler .Update (100 ); // point.X == 5
78+ handler .Update (100 ); // point.X == 10
79+ ````
80+
4381### Events
4482```C #
4583point .Tween (x => x .X ).To (20 ).In (0 . 5 ).Delay (1 . 0 )
@@ -58,9 +96,7 @@ handler.Update(200); // point.X == 4 OnUpdate called
5896handler .Update (200 ); // point.X == 6 OnUpdate called
5997handler .Update (200 ); // point.X == 8 OnUpdate called
6098handler .Update (200 ); // point.X == 10 OnUpdate called, OnComplete called
61- handler .Update (100 ); // point.X == 10 (Tween has ended)
62-
63-
99+ handler .Update (100 ); // point.X == 10 (tween has ended)
64100 ````
65101### Repeat
66102You can specifiy repeat actions .
@@ -78,6 +114,16 @@ point.Tween(x => x.X).To(20).In(0.5).Delay(1.0).Repeat(1)
78114 .OnComplete (OnCompleteHandler ); // gets called after 2 seconds (delay + duration + repeat duration)
79115 ````
80116
117+ ### Time
118+ Through time modifiying you can achieve slow - or fast - motion effects .
119+ ```C #
120+ handler .TimeModifier = 0 . 5 ; // runs tweens at half speed
121+ handler .TimeModifier = 2 ; // runs tweens at double speed
122+
123+ // You can even tween this property
124+ handler .Add (handler .Tween (x => x .TimeModifier ).To (0 . 5 ).In (0 . 5 ).Yoyo (true ).Repeat (1 ));
125+ ````
126+
81127### Custom tween operations
82128You can specify custom functions for tweening properties
83129```C#
@@ -114,6 +160,7 @@ public static UInt32 ColorProgressFunction(UInt32 startValue, UInt32 endValue, d
114160}
115161
116162var someObjectWithColor = new SomeObjectWithColor { Color = 0x ff0000ff } // Color is UInt32
163+
117164// tween blue to red in 1 second
118165someObjectWithColor (x => x .Color , ColorProgressFunction ).To (0x ffff0000 ).In (1 . 0 );
119166````
0 commit comments