Raitch Posted April 15, 2014 Share Posted April 15, 2014 I'm going to face a problem in my project where I wish to slow down active tweens based on dynamic conditions. From what I've found I could either use tween's `generateData()` or `pause()` and `resume()` to achieve this. However pausing and resuming might cause a lag-like effect, and `generateData()` requires me to reinvent tweens to a certain degree, plus if I wish to half the speed I need to generate in 120fps for instance, which might cause more unnecessary processing power when it's not needed. Does anyone have any input regarding these solutions, or know a better one fitting my needs? Basically I need to slow down the animation of a tween so that the callback gets delayed and so on. Link to comment Share on other sites More sharing options...
rich Posted April 15, 2014 Share Posted April 15, 2014 Honestly, don't use the built-in tween system. Instead use something like Greensock and then you can take advantage of its timeScale features: http://www.greensock.com/gsap-js/ Link to comment Share on other sites More sharing options...
Raitch Posted April 24, 2014 Author Share Posted April 24, 2014 Roger that. I've applied this tween to my game now and it works like a charm. However, is there any easy way for me to make the tween pause when everything else pauses? Or would I have to run every tween through these calls? http://www.html5gamedevs.com/topic/3054-detect-when-the-game-change-visibility/ Link to comment Share on other sites More sharing options...
george Posted April 24, 2014 Share Posted April 24, 2014 Yes, you have to listen for the onPause event. You can pause everything in tweenmax with TweenMax.pauseAll(). But I remember that I had some problems with timelines so I used 'globalTimeScale' instead. With this nothing gets paused, instead the time scale will actually be set to a very very small number as 0 is not allowed and the tweens will run very very very slow- like they are paused. But maybe you're not using timeline's at all- in this case try tweenmax#pauseAll first.//pauseTweenMax.globalTimeScale(0)//resumeTweenMax.globalTimeScale(1) Link to comment Share on other sites More sharing options...
Recommended Posts