Bonilka Bonilka - 11 months ago 124
Dart Question

How create loop tween?

I'm using stagexl (on dart lang) for my game. I tried find in api how restart tween after it will be complete, but could not. Can you help me? Thnx.


You can not restart a Tween, you have to create a new one. You could also use the new async methods like juggler.onElapsedTimeChange, juggler.interval or juggler.timespan. Or you could implement your own tween-like class which implements the Animatable interface.

Here is an example for the juggler.interval method:

await for (var counter in juggler.interval(delay).take(666)) {
  // do something 666 times.

Here is an example for juggler.onElapsedTimeChange

await for (var time in juggler.onElapsedTimeChange) {
  // do something with time.

Here is an exmaple for the Animatable interface

class MyAnimation implements Animatable {
  bool advanceTime(num time) {
    // do something with time
    return true; // animation should continue on next frame

Please check out the Juggler documentation: