Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are cocos2d scheduled methods run in another thread?

We can use scheduleUpdate or schedule:@selecotr(xxx) to schedule a method to run.

Is the scheduled method run in another thread?

like image 449
Terry Z Avatar asked Jan 19 '13 13:01

Terry Z


2 Answers

No. Cocos2d objects are not thread-safe and expected to run on main thread. The timer is scheduled on the main run loop. So do not block main thread under any circumstance.

like image 181
Bryan Chen Avatar answered Nov 01 '22 18:11

Bryan Chen


You can use [self performSelectorInBackground:…] and similar NSObject methods.

The usual caveats apply. Almost every property in cocos2d is marked "nonatomic" and is therefore not thread-safe, so you may run into common multithreading issues unless you know exactly what you're multithreading, and why you're doing it.

like image 32
LearnCocos2D Avatar answered Nov 01 '22 17:11

LearnCocos2D