Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We are using Cocos 2D for Android and are unsure if it's a good thing to execute our non-ui tasks on the Cocos thread as a way to get the animations in our game to pause.

What is the recommended practice?

share|improve this question
are you talking about cocos2d-x? – Ali.S Jun 24 '11 at 19:08
even if not, and if you are familiar with c++ i recomment switching into it, since you can easily port your game to iphone using that engine. – Ali.S Jun 24 '11 at 19:39
Did you want your game to pause, or just the animations? You may find this question handy. – Keeblebrox Jun 24 '11 at 20:29
up vote 1 down vote accepted

So as it turns out you should put as little on the Cocos thread as you can. Things you schedule here get run for every frane! It's sometimes an easy way to get things synced between GUI and background logic, but it will make your game slow.

share|improve this answer

Thread are something that you have to avoid as long as possible. sure they make all the thing easier in some conditions but they may also create some enexpeted behavior that are really hard to trace. so for your example i prefer some flag to stop update functions to do their animate jobs since you can easily implement it that way.

in general specially for iphone/android that using threads doesn't give any boost in performance (and sometimes might even reduce fps) I prefer to do all the jobs by hand. except some very rare cases such as loading game content while playing animations there is no need to use threads at all, so you have to avoid using them.

share|improve this answer
The iPad2 and dual-core Android devices could potentially see a performance boost for threaded games. – Keeblebrox Jun 24 '11 at 19:48
@Keeblebrox: i don't think that's really the case. normally android/ios games don't use that much computional power. and when you are developing an application for ios/android you usually target all devices, and not all of them have two cpu cores! – Ali.S Jun 24 '11 at 19:56
All of them support threading, though. At worst his game would perform slightly worse on older devices than on newer devices. He could also see large performance boosts on dual-core devices, depending on how computationally complex his game is. – Keeblebrox Jun 24 '11 at 20:10
@Keeblebrox: i meant not in not all of them you have perfomance boost, and for god's sake just take a glance at what he is going to use threads for! it's not because of performance boost! he only want to have a thread to pause whenever he press pause button instead of ignoring update calls! – Ali.S Jun 24 '11 at 22:02
I was directing my comments about threading more to your point that you should avoid it as much as possible and less about his situation in particular; I'm sorry about the confusion. His question doesn't mention creating a thread for pausing, however; he's asking whether he should run non-UI tasks in the UI thread in order to stop animation. – Keeblebrox Jun 24 '11 at 22:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.