How To Reference The AppDelegate

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:

Cheers,
Dean

include “AppDelegate.h”

Access it like this:

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

Make sure AppDelegate has the following code:

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

AppDelegate::~AppDelegate()
{
CC_ASSERT(this == s_pSharedAppDelegate);
s_pSharedAppDelegate = NULL;
}

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