compile error , when i override the ccTouchBegan method in class HelloWorld:public cocos2d::CCLayer


#1

my code in HelloWorld:public cocos2d::CCLayer
is :

public: virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent); virtual void ccTouchEnded (CCTouch *pTouch, CCEvent *pEvent); virtual void ccTouchCancelled (CCTouch *pTouch, CCEvent *pEvent); virtual bool ccTouchBegan(CCTouch* pTouch ,CCEvent* pEvent);

i compile it in Visual Studio 2012
and the compiler error message is that:
1>e:2d-2.1beta3-x-2.1.1\graduation\graduation\classes\helloworldscene.h(48): error C2061: syntax error : identifier ‘CCTouch’
1>e:2d-2.1beta3-x-2.1.1\graduation\graduation\classes\helloworldscene.h(49): error C2061: syntax error : identifier ‘CCTouch’
1>e:2d-2.1beta3-x-2.1.1\graduation\graduation\classes\helloworldscene.h(50): error C2061: syntax error : identifier ‘CCTouch’
1>e:2d-2.1beta3-x-2.1.1\graduation\graduation\classes\helloworldscene.h(52): error C2061: syntax error : identifier ‘CCTouch’

i can’t figure out the problem from that message ? so any one can help ? many thanks !


#2

Compiler doesn’t know where to find CCTouch. Append the namespace cocos2d before it so that it can find it. Something like: cocos2d::CCTouch pTouch* and cocos2d::CCEvent pEvent*


#3

or USING_NS_CC;