mazoku Posted April 19, 2017 Share Posted April 19, 2017 I have yoyo tween. I want to pause and resume from the start. I don't want to create many tweens. Is there a way? Link to comment Share on other sites More sharing options...
spinnerbox Posted April 19, 2017 Share Posted April 19, 2017 https://phaser.io/examples/v2/category/tweens https://phaser.io/examples/v2/tweens/pause-tween https://phaser.io/examples/v2/tweens/yoyo Also consult the Tween API You can add events onStart, onComplete, onRepeat, onLoop Link to comment Share on other sites More sharing options...
mazoku Posted April 19, 2017 Author Share Posted April 19, 2017 Sorry but nothing of these is not answering my question. I need something like calling stop and then start again. Pause is stopping the tween and resume continues from where it starts. After stop the tween is marked for deletion and has some strange behavior. Link to comment Share on other sites More sharing options...
spinnerbox Posted April 19, 2017 Share Posted April 19, 2017 I don't think tweens are designed to be fiddled like timers. It just starts and works until it reaches the end state. You can pause it but cannot reset it. Recreate the tween with same settings, to reset it from start, maybe? You could also play with timers and set properties of game objects with timers. But I don't know how Yoyo curve looks like Set a value for a game object property calculated by Yoyo function at a given time. Since it will be a timer, you can stop, pause, reset, loop... Link to comment Share on other sites More sharing options...
spinnerbox Posted April 19, 2017 Share Posted April 19, 2017 Which one of these is Yoyo? http://sole.github.io/tween.js/examples/03_graphs.html Link to comment Share on other sites More sharing options...
samid737 Posted April 19, 2017 Share Posted April 19, 2017 here is an example of how you can reset the same tween without adding a new one: The key parameter that determines where the tween continues is found in the timeline property of the tween : tween.timeline[0].dt . If you reset that to 0 it will start from the beginning. The example has a bit more features where it resets the tween when pressing the A button. However, its more tedious to work this way and the simplest way out is to add it again, but if you really require the same tween then this could be a solution. AhmedElyamani, Cudabear, mazoku and 1 other 4 Link to comment Share on other sites More sharing options...
mazoku Posted April 19, 2017 Author Share Posted April 19, 2017 If I add it again at some point I'll create tons of tweens once and garbage collect them later. Not the best thing to do when you need performance. samid737 thank you! This is exactly what I need. samid737 1 Link to comment Share on other sites More sharing options...
mazoku Posted April 20, 2017 Author Share Posted April 20, 2017 I can't make it work with yoyo tween. No problem with simple tweens. Link to comment Share on other sites More sharing options...
Recommended Posts