Hello everyone, I look forward to helping the following:
I want to create tween of different nodes and run them one by one. But I failed. I read the documentation but could not find any suitable function.
At first I used the then() function but it did nothing. After that I used the call() function, it seemed to work a bit, but it was really not okay if the number of tween increased.
I really don’t know what to do, I hope everyone answers. Thank you in advance.
‘’’
onEnable()
{
for (let current of this.allNodes)
{
current.anyNode.opacity = 100;
}
this.moveTitle()
.call(
() => this.fadeInAllNodes().call(
() => this.moveCursorToDrag().start()
).start()
).start();
}
private moveTitle(): cc.Tween<cc.Node>
{
let originalPosition = this.title.getPosition();
this.title.setPosition(0, 0);
let thisTween = cc.tween(this.title)
.to(0.5, { scale: 1.5, easing: cc.easeBounceOut })
.to(1, { scale: 1, easing: cc.easeCubicActionIn })
.delay(0.5)
.to(1, { position: originalPosition });
return thisTween;
}
private fadeInAllNodes(): cc.Tween<cc.Node>
{
let allTweens: Array<cc.Tween<cc.Node>> = [];
for (let current of this.allNodes)
{
allTweens.push(cc.tween(current.anyNode).to(current.fadeSpeed, { opacity: 255 }).delay(this.waitTimeBetweenNode));
}
for (let i = 0; i < allTweens.length; i++)
{
if (i + 1 < allTweens.length)
{
allTweens[i].call(() => allTweens[i + 1].start());
}
}
return allTweens[0];
}
private moveCursorToDrag(): cc.Tween<cc.Node>
{
let moveCursor = cc.tween(this.cursor)
.to(1, { position: this.drag.getPosition() })
.delay(1)
.to(1, { position: this.drop.getPosition() })
.start();
let moveDrag = cc.tween(this.drag)
.delay(2)
.to(1, { position: this.drop.getPosition() })
.start();
return moveDrag;
}
‘’’