how to use chain when you want to update separate tween animaton?
hello,here is my code
const tweenA = new Tween(tweenStateInit)
.to({ x: 100 }, 300)
.onUpdate(({ x }) => {
update(x);
})
.onComplete(() => {
console.log('tweenA end');
});
const tweenB = new Tween(tweenStateOne)
.to({ x: 200 }, 300)
.onUpdate(({ x }) => {
update(x);
})
.onComplete(() => {
console.log('tweenB end');
});
const tween = tweenA.chain(tweenB).start();
// loop
loop(){
// ...
tween.update()
}
I want to use chain to paly two animation. When playing the first, i update the first 'x',when playing the next, it seems lost efficacy. chain returns the first tween object, there is no way to update the another tween?
Hope someone answer,please!
hello,here is my code
const tweenA = new Tween(tweenStateInit) .to({ x: 100 }, 300) .onUpdate(({ x }) => { update(x); }) .onComplete(() => { console.log('tweenA end'); }); const tweenB = new Tween(tweenStateOne) .to({ x: 200 }, 300) .onUpdate(({ x }) => { update(x); }) .onComplete(() => { console.log('tweenB end'); }); const tween = tweenA.chain(tweenB).start(); // loop loop(){ // ... tween.update() }I want to use chain to paly two animation. When playing the first, i update the first 'x',when playing the next, it seems lost efficacy. chain returns the first tween object, there is no way to update the another tween?
Hope someone answer,please!
it seems that i need to use tweenB.update() in RAF, tween.update() only effect on tweenA The state I want is that as long as you call tween.update, you can be heard by tweenA and tweenB's onUpdate, but now only tweenA's onUpdate executes it
The trick is to add both tweens to a TWEEN.Group then call update on the group:
tweenA.chain(tweenB).start();
const group = new Group()
group.add(tweenA)
group.add(tweenB)
// loop
loop(){
// ...
group.update()
}
The trick is to add both tweens to a
TWEEN.Groupthen callupdateon the group:tweenA.chain(tweenB).start(); const group = new Group() group.add(tweenA) group.add(tweenB) // loop loop(){ // ... group.update() }
Thank you very much, i get what you mean,and you can close this issue now!😀
You're welcome! :)