Terry Z
Terry Z

Reputation: 329

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?

Upvotes: 5

Views: 933

Answers (2)

CodeSmile
CodeSmile

Reputation: 64477

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.

Upvotes: 1

Bryan Chen
Bryan Chen

Reputation: 46608

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.

Upvotes: 9

Related Questions