We are building a content editor that brings up a "cocos Player" in an NSWindow
for test purposes. The user can test some content and then close the window.
So I need to be able to shutdown cocos and re-start within the same app.
Everything is working if I use the CC_MAC_USE_DISPLAY_LINK_THREAD
threading model. I had to make a fix in CCDirectorMac
to get this working. In CCDirectorMac | stopAnimation
I had to set the _runningThread
to nil
since it is not set to nil by the #if
and #elif
when using CC_MAC_USE_DISPLAY_LINK_THREAD
.
Anyway so now I am able to "end" a director and then re-start it later with no issues.
My question though is this: If I am building an AppKit editor with occasional use of cocos2D whould my threading model really be CC_MAC_USE_MAIN_THREAD
as is suggested in the documentation?
When I do use CC_MAC_USE_MAIN_THREAD
I get a HANG in in stopAnimation
on the line:
CVDisplayLinkStop(displayLink);
I think the main thread would be fine and would avoid threading issues for our tool. Performance is not a concern. I can't find any sample code that shuts down and restarts cocos2d in an NSWindow
... so my assumption here is that I am in untested waters (or little tested waters).
My steps to shutdown/restart are:
- Call
[[CCDirector sharedDirector] end]
- This calls
stopAnimation
- Then re-initialize cocos2d the same way I did originally
Any advice on threading models for a Mac desktop app ... and why CVDisplayLinkStop
hangs would be greatly appreciated.
Thanks in advance.