cc.Delay not working inside cc.Sequence

I have the below code:

 var seq = cc.sequence(cc.delayTime(5), this.LoadNextScene(),);
 runAction(seq);

This is triggered by clicking on a button in the Cocos Creator scene. The LoadNextScene function loads another scene with cc.director.LoadScene(“NextScene”).
When I press the button the NextScene is loaded instantly.
The sequence should have a 5 second delay first so why doesn’t the delay work?


try:
cc.sequence(cc.delayTime(5), cc.callFunc(() => this.LoadNextScene()));

1 Like

What Ronsku posted, you have to wrap the function call inside cc.callFunc to mark it is a callback function. Otherwise the complier thinks this is a function call who’s return value will be passed as the parameter to cc.seq. But since it runs code to switch scenes then the runAction call is never reached. So it looks like the sequence is running but truly it never is.