How can i get the instance of AppDelegate in cocos2d-x juse like the [AppDelegate sharedAppDelegate] in cocos2d;
You can add this method to AppDelegate, or using ‘((AppDelegate*)CCApplication::sharedApplication())’.
If use ‘((AppDelegate**)CCApplication::sharedApplication)’.will get a error:Cannot cast from type ’cocos2d::CCApplication’ to pointer type ’AppDelegate**’And ,I also try this:dynamic_cast<AppDelegate*>(&CCApplication::sharedApplication()).But it can’t work on Xcode.Google said it can work on vc.
James Chen wrote:
You can add this method to AppDelegate, or using ‘((AppDelegate*)CCApplication::sharedApplication())’.
dynamic_cast(&CCApplication::sharedApplication()) returns NULL on Xcode
James Chen wrote:
You can add this method to AppDelegate, or using ‘((AppDelegate*)CCApplication::sharedApplication())’.