Jump to content

Revamping tweens


powerfear
 Share

Recommended Posts

Right now when chaining tween, there is no easy way to stop or start a chain of tween. If you stop or start the first tween of the chain it will simply stop / start itself which won't affect anything if the currently running tween in the chain is not the first tween. If you look at my lattest pull request you can test this with the phaser/examples/tweens/chained tweens.php example. Now there is a couple of different way to implement this and this is why I posted this. I want your opinion on how to do this.

 

Here is some stuff to consider

 

While chaining .to calls will produce a "line of tween", chaining tween directly with .chain allow for more then one tween per tween so it can creates a branching scenario. Should .chain also be supported to start/stop?

 

Here is what i mean by branching, a single tween could have 3 other tweens added to it, while this could be simple to solve for only 2 level of chaning, the branching could also go on for a while and with different tweens lenght.

to - to - to       chainchain /- chain      \chain

I found there is two easy solution to offer starting and stopping a chain of tween, having a variable on the parent tween keeping track of wich tween in the chain is currently playing, then either

 

1. checking what is calling start, if its not the tween currently playing, recall start making the currently playing tween the this context.

2. Rewritting start with a self/this system. This avoid 1 function call, but this is very minor performance improvement.

3. Any suggestions you have.

 

For the stop function its simpler there is about no logic in it so it's only about removing the currently playing tween from the manager rather then the calling tween.

Link to comment
Share on other sites

Hmm there's also the situation where a tween that is part of a chain could be actively deleted by the TweenManager long before the chain is completed, so if the chain was set to loop the reference to the first tween would be gone.

 

I think an easier (well, more flexible!) solution might be to create a TweenGroup in which tweens are added to and played in sequence. A Group could have properties like being able to be paused, resumed, looped, yoyo'd, etc. This could in essence maybe replace chaining altogether.

Link to comment
Share on other sites

Yeah that's what I meant :)

 

I'm pretty sure TweenMax has a nice implementation of "groups" (they call them something else though). Might be worth looking at too, but I'm sure we've got the basics down already.

 

I think the only really important decision is if TweenManager processes Groups first, then tweens? Or something else.

 

Anyway I'll do a push now with the updated tween files in.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...