How To Reference The AppDelegate

How To Reference The AppDelegate
0.0 0


Hello everyone,

With the help of this forum I’ve managed to release ‘ThrowEmBalls’ on Android and iPhone. I am now developing it for the Windows Phone.

However, I am unable to reference the AppDelegate on the Windows Phone. On the Android I used the following code:

AppDelegate* delegate = (AppDelegate**)CCApplication::sharedApplication;
and on iPhone I used:
AppController**delegate = [[UIApplication sharedApplication] delegate];

What would be the equivalent code for the Windows Phone?

Any ideas?!? Help :slight_smile:



include “AppDelegate.h”

Access it like this:

@ AppDelegate& app = AppDelegate::sharedAppDelegate();@

Make sure AppDelegate has the following code:

// sharedApplication pointer
AppDelegate * s_pSharedAppDelegate = 0;
CC_ASSERT(! s_pSharedAppDelegate);
s_pSharedAppDelegate = this;

CC_ASSERT(this == s_pSharedAppDelegate);
s_pSharedAppDelegate = NULL;

// static function to get app pointer
AppDelegate& AppDelegate::sharedAppDelegate()
return *s_pSharedAppDelegate;