diff --git a/README.md b/README.md index cd7ad89..b99a86f 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,31 @@ void loop() { } ``` +## Add Transition to Sequence Dynamically + +You can add transitions to your sequence dynamically like this: + +```C++ +float a = 0; +timeline.add(a).init(0).then(5, 1000); +timeline.start(); + +// do some stuff... + +// dynamically append transition to sequence of "a" +timeline.append(a, 10, 5000); +``` + +This is same as following manual operation: + +```C++ +timeline[a].then(0, 5000); +timeline.update_duration(); +``` + +See `dynamic_append` example for the details. + + ## Control Timeline with Mode, Auto Erase, and Offset ### Timeline Mode @@ -202,8 +227,14 @@ for (size_t i = 0; i < 5; ++i) { ```C++ template Sequence& add(T& target, const bool b_auto_erase = false); +template +void append(const T& target, const U& to, const double in); +template +void append(const T& target, const double in); +void update_duration(); void start(); +void restart(); bool update(); void clear(); @@ -216,9 +247,28 @@ void auto_erase(const bool b); size_t size() const; template -const Sequence& operator[](const T& t); -template -Sequence& operator[](T& t); +Sequence& operator[](const T& t); +``` + +`Timeline` is derived from [FrameRateCounter](). So its methods to control timeline are also available. Some useful methods are listed below. + +```C++ +virtual void start(); // overridden by Tween::Timeline +virtual void stop(); +virtual void play(); +virtual void pause(); +virtual void restart(); // overridden by Tween::Timeline +virtual void clear(); // overridden by Tween::Timeline + +void startFromSec(const double from_sec); +void startForSec(const double for_sec, const bool loop = false); +void startFromForSec(const double from_sec, const double for_sec, const bool loop = false); + +bool isRunning() const; +bool isPausing() const; +bool isStopping() const; + +double sec(); // get current time of timeline ``` ### `Sequence`