Xcode vs Visual Studio - callfuncO_selector()


#1

I am working with some code that compiles with Xcode but doesn’t compile with Visual Studio.

This is the line that compiles in Xcode but not Visual Studio and the error it gives:

// Visual Studio Error: error C2440: ‘type cast’ : cannot convert from ‘void (__thiscall HelloWorld::* )(LHContactInfo *)’ to ‘cocos2d::SEL_CallFuncO’
lh->registerBeginOrEndCollisionCallbackBetweenTagA(PLAYER, COIN, this, callfuncO_selector(HelloWorld::mouseCoinCollision));

This is the declaration of mouseCoinCollision():

void HelloWorld::mouseCoinCollision(LHContactInfo* contact)

Does anyone more familiar with Xcode than I understand why it works there and not in Visual Studio?

I converted most of the new tutorial located here: http://www.levelhelper.org/?p=1778 to cocos2d-x and also got it to run on my Kindle Fire using Marmalade but have just the problem above. Attached is a pic of it running on the Kindle Fire.

Thanks

Francis


kindleTutorial.jpg (52.0 KB)


#2

The problem seems to be Visual Studio C++. The above problem was worked around by changing:

void HelloWorld::mouseCoinCollision(LHContactInfo* contact)

to

void HelloWorld::mouseCoinCollision(CCObject* contact)

and typecasing contact to LHContactInfo when it is used.