In this code: my_layer.do(Delay(10) + CallFunc(my_func)), why it executes my_func() at once instead of execute if after delaying 10s?

9 views
Skip to first unread message

che...@sina.com

unread,
May 23, 2018, 1:41:27 PM5/23/18
to cocos2d discuss
so, how to do delay/wait in cocos?

My purpose is, wait for a few seconds, and then kill the current layer。

claudio canepa

unread,
May 23, 2018, 1:55:08 PM5/23/18
to cocos2d discuss
Hi,

On Wed, May 23, 2018 at 10:56 AM, <che...@sina.com> wrote:
so, how to do delay/wait in cocos?
In this code: my_layer.do(Delay(10) + CallFunc(my_func)), why it executes my_func() at once instead of execute if after delaying 10s?
My purpose is, wait for a few seconds, and then kill the current layer。

-

The syntax you show in the title should work; as can be seen in the example test\test_callfunc.py

Are you sure is the same syntax you used in the failing code? By example, these two variants will call without delay

my_layer.do(Delay(10)) + CallFunc(my_func)
my_layer.do(Delay(10) + CallFunc(my_func())



che...@sina.com

unread,
May 23, 2018, 10:08:18 PM5/23/18
to cocos2d discuss
Thanks Claudio for your reply.

you are right, I checked my code, found I used the following syntax :

my_layer.do(Delay(10) + CallFunc(my_func())

After removing () following by my_func, delay works.
Reply all
Reply to author
Forward
0 new messages