Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Time scale #266

Open
Tomucha opened this issue Feb 17, 2017 · 3 comments
Open

Suggestion: Time scale #266

Tomucha opened this issue Feb 17, 2017 · 3 comments

Comments

@Tomucha
Copy link

Tomucha commented Feb 17, 2017

Hi!

I would like to have "double timeScale" property in RenderLoop. I want player to be able to speed game up or slow it down. It seems to me that this would be pretty straight forward change. Right here:

https://github.com/bp74/StageXL/blob/master/lib/src/display/render_loop.dart#L47

Just multiply deltaTime by timeScale, IMHO.

@bp74
Copy link
Owner

bp74 commented Feb 17, 2017

Hi Tomas,

Do you use the Juggler? You could do something like this:

class TimeLapseJuggler extends Juggler {
  num speed = 2.0;
  bool advanceTime(num time) {
    super.advanceTime(time * speed);
  }
}

var myJuggler = new TimeLapseJuggler();
renderloop.juggler.add(myJuggler);

Now you use this juggler for all your animations. You can also change the the "speed" property to change the speed of the playback.

@bp74
Copy link
Owner

bp74 commented Feb 17, 2017

Btw. this is the prefered technique to implement a "pause" button. You use your own instance of Juggler and if you want to pause the game, you just remove your juggler from the main juggler.

// pause
renderloop.juggler.remove(myJuggler);

// continue
renderloop.juggler.add(myJuggler);

@Tomucha
Copy link
Author

Tomucha commented Feb 19, 2017

Good tip, thanks!

I don't like keeping my own reference to my specialised Juggler, because anyone can call "stage.juggler" and "escape my time scale". Please consider allowing me to create RenderLoop instance with my own "root" Juggler in constructor.

In my case I have overridden RenderLoop itself so I can have this "time scale" behaviour global. (My UI isn't in StageXL, so I don't need any exceptions from this global time scale, and I want to make sure that everything respect it.)

Anyway, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants