Cannot build airplay HelloWorld with 0.9.2

Hi,

I cannot build HelloWorld with 0.9.2 (though on 0.9.1 all works fine, except usage of obsolete names HelloWorld.mkb).

First HelloWorld.mkb needs to be updated to fit recent sources structure, to take files:
AppDelegate.h
AppDelegate.cpp
HelloWorldScene.h
HelloWorldScene.cpp

from …/Classes rather than …/.

Next error, my vc2008 outputs following error when thrying to build HelloWorld solution:

Error 4 error C2039: ‘setDelegate’ : is not a member of ‘cocos2d::CCAccelerometer’ d:2dx\cocos2d-1.0.1-x-0.9.2\cocos2dx\layers_scenes_transitions_nodes\cclayer.cpp 151 HelloWorld_vc9

Error 9 error C2471: cannot update program database ‘d:2dx\cocos2d-1.0.1-x-0.9.2\helloworld\airplay\build_helloworld_vc9\debug_helloworld_vc9_x86\vc90.pdb’ d:2dx\cocos2d-1.0.1-x-0.9.2\cocos2dx\layers_scenes_transitions_nodes\ccscene.cpp 1 HelloWorld_vc9

Did anyone see this problem?

Thanks,
Alex

Hey! I just came across the same thing when I tried to upgrade to 0.9.2….

It looks like “setDelegate” has been replaced with calls to “addDelegate” and “removeDelegate”…. So whenever in the code it seems like you’re adding a delegate, call “addDelegate” instead, and vice versa.

I’m not 100% sure if all my changes were correct…. but it works with the AirPlay simulator using the accelerometer…. and I’ve tested it for about 5 minutes without any faults….

The one thing that didn’t follow the above changes was in this file, where I just replaced the methods with what you see below.

cocos2dx\platform\airplay\CCAccelerometer_airplay.cpp

CCAccelerometerHandler::~CCAccelerometerHandler()
{
}

void CCAccelerometerHandler::setDelegate(CCAccelerometerDelegate *pDelegate)
{
    if (pDelegate)
    {
        CCAccelerometer::sharedAccelerometer()->addDelegate(pDelegate);
    }

    if (m_pDelegate)
    {
        CCAccelerometer::sharedAccelerometer()->addDelegate(m_pDelegate);
    }
    m_pDelegate = pDelegate;
}

Hope it helps!

Brad

Whoops! That second line is supposed to be “removeDelegate”, not addDelegate… and to be more clear, if it used to be setDelegate(NULL), then do removeDelegate(this) most of the time…. And once again, not sure if this is how it’s supposed to be done, but it works :wink:

CCAccelerometerHandler::~CCAccelerometerHandler()
{
}

void CCAccelerometerHandler::setDelegate(CCAccelerometerDelegate *pDelegate)
{
    if (pDelegate)
    {
        CCAccelerometer::sharedAccelerometer()->addDelegate(pDelegate);
    }

    if (m_pDelegate)
    {
        CCAccelerometer::sharedAccelerometer()->removeDelegate(m_pDelegate);
    }
    m_pDelegate = pDelegate;
}

Thanks for feedback Brad. However I’ve decided currently to stay at 0.9.1 since 0.9.2 seems to be buggy at the moment (even though it’s called stable:)).

Alex

I was still getting errors for the Airplay (Marmalade) platform with the above changes with the cocos2d-x 0.9.2 with the accelerometer refactoring for all the platforms except Marmalade.

I made the changes to the platform specific files following the Anrdoid implementation.

The code attached worked with the Tweejump game in the Marmalade simulator so I’m assuming it will work on the device.

Regards,

Francis

ohh well, i am trying to sort out the same from past 3 days… and now i am switching back to 9.1 :slight_smile: thank u