-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathTimelinePartSample.hx
40 lines (31 loc) · 1.2 KB
/
TimelinePartSample.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sample.Sprite;
import sample.Square;
import tweenxcore.structure.FloatChange;
import tweenxcore.structure.FloatChangeRepeatPart;
import tweenxcore.structure.FloatChangeTimelinePart;
import tweenxcore.structure.Timeline;
using tweenxcore.Tools;
class TimelinePartSample extends Sprite {
public static var TOTAL_FRAME:Int = 80;
private var square:Square;
private var frameCount:Int = 0;
private var timeline:Timeline<FloatChangeTimelinePart->Void>;
public function new() {
super();
addChild(square = new Square());
timeline = new Timeline().add(update1, 1).add(update2, 2).add(update3, 5);
}
public function update():Void {
var floatChange = new FloatChange(frameCount, frameCount += 1);
floatChange.handleTimelinePart(0, 80, timeline);
}
private function update1(part:FloatChangeTimelinePart):Void {
square.x = part.current.lerp(0, 450);
}
private function update2(part:FloatChangeTimelinePart):Void {
square.y = part.current.cubicInOut().lerp(0, 120);
}
private function update3(part:FloatChangeTimelinePart):Void {
square.x = part.current.quartIn().cubicIn().lerp(450, 0);
}
}