28
Jul
12

Thread issues

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?

Image

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”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


Categories


%d bloggers like this: