How to delay a method call by 1 second?

I want to call a method after every 4th game over in my game , but I’m not sure do I use a timer or what would be the best way to implement this ?

The subject line didn’t match your question.

You want a method every x-th game start or do you want a method to be called by a delay?

1 Like

I use SQLite or UserDefaults for this type of thing. I store values in a table and then I read that table on startup. I also then update the table as my game changes while being played.

I want a method to be called by delay, I was just throwing it in there that the method will be called every 4th game over

use a delay action and a lamda

2 Likes

Is there sample code for this in the docs ?

3 Likes

@dimon4eg saves the day once again :pray:t3: , so I just call this scheduleOnce code every time I want to call the method ?

Thank you :joy::joy:

1 Like

Yup, is not it easy? :wink:

1 Like

Yup !! Super easy :slight_smile:

We do have this code here:

https://docs.cocos2d-x.org/cocos2d-x/en/actions/getting_started.html

and

https://docs.cocos2d-x.org/cocos2d-x/en/actions/basic.html at the bottom.

I’ll add a more concrete example to the docs now.

1 Like