Cocos2DXNA / cocos2d-xna

XNA Port of Cocos2d-X
www.cocos2dxna.com
227 stars 123 forks source link

Dispose and re-create game support #314

Closed totallyeviljake closed 10 years ago

totallyeviljake commented 11 years ago

in the windows phone 8 Xaml world, a user wants to use the Xaml UI tools to create a nifty pre-game interface. then when the user enters the game, be able to create the XamlGame implementation from MonoGame. Then when the user exists the game and enters the Xaml UI, they would like to dispose of the entire Game context so that they can re-create it from scratch should the user re-enter the game.

This requires that the static state of cocos2d-xna and the XNA runtime be adequately collected and flushed so that a new Game object can be constructed.

cuongdm commented 10 years ago

Please consider about this isusue!

totallyeviljake commented 10 years ago

There is a "bug" in the SharpDX 2.5 and MonoGame interaction that precludes the functioning of this process. Some buffers in SharpDX are not disposed when the game is disposed, which then causes some internal state to interfere with MonoGame reinitializing itself properly. We've recently tried to work around this, but nothing has been successful.

cuongdm commented 10 years ago

Thanks for tried to work about this problem. Please notice me when issue has resolved. This is important feature to create a game base on Windows phone 8

totallyeviljake commented 10 years ago

Note that we have games on WP8 and they work just fine without having to recreate the game object.

Make sure that you are navigating through your XAML properly and not trying to reload a Xaml page that also automatically navigates to the game Xaml page.

cuongdm commented 10 years ago

Thanks for support, my game worked fine!

totallyeviljake commented 10 years ago

Another user has reported a similar bug to this issue.

totallyeviljake commented 10 years ago

I think we figured this one out too. The CreateStats code would cause the main loading thread to halt forever, so we rewored the CCDirector to create the stats label when needed. That seemed to fix the stats display on WP8 and I no longer see any unexpected halting on startup.