Today I encountered something that *might* become a problem unless I find some neat workaround. It seems one can’t create texts in Cocos2d from another thread than the main one. This is really not so good since the RePlay must run on a background thread due to the fact that it can take several minutes to finish. You don’t want to block the main thread for that long.
So either I must rewrite the whole RePlay routine to work on callbacks and timers instead (yuck) or there might be some kind of workaround by forcing the text specific calls to be run on the main thread.
Because it really can’t look like this, right?
Edit: Yes, found a solution. There’s a way in Objective-C to tell something to run on a certain thread other than the one you’re at so i encapsulated the calls where there are texts involved inside that strange dispatch-call. I have no idea how it works but I don’t care either as long as I can use it 😉
Looks a lot better now, right?
0 Responses to “Thread issues”