Jump to content

multiple timelines


old_blueyes
 Share

Recommended Posts

Hi,

Is it possible to run 2 separate timelines one after another?

i.e. using the onComplete parameter on the first timeline to fire a function which contains the second timeline.

using something similar to this:

            var timeline = this.tweens.timeline({

                tweens: [{
                    targets: targs,
                    x: startPos,
                    duration: startDur,
                    ease: 'Sine.easeInOut',
                    delay: delay
                },
                {
                    targets: targs,
                    x: jostlePos,
                    duration: lineDur,
                    ease: 'Sine.easeInOut',
                    yoyo: true,
                    repeat: 2,
                    onComplete: function () {
                    
                        var timeline2 = this.tweens.timeline({

                            tweens: [{
                                targets: targs,
                                x: 1000,
                                duration: raceDur,
                                ease: 'Sine.easeInOut',
                                delay: delay
                            }]
                            
                        });
                        
                        console.log('complete');
                        
                    }
                        
                    }]

            });

All i get is Cannot read property 'timeline' of undefined, which is referring to the second timeline, as the first plays without bother

Link to comment
Share on other sites

Your second this.tween.timeline is out of scope; 'this' has no reference to tweens.timeline.  You can define:

var _this = this;

...outside of the first tween, and in the onComplete call: _this.tweens.timeline.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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