C++ cocos2dx中CCStandredTouchDelegate的类歧义错误(从驱动类的歧义转换)?
我正在子类化一个CCSprite,以便为sprite对象做旋转手势 为此,我需要使用CCTargetedTouchDelegate和CCStandardTouchDelegate 但即使在声明了这些委托的函数之后,我也会得到一个模糊错误 错误屏幕截图:- 我的.h文件中的代码。C++ cocos2dx中CCStandredTouchDelegate的类歧义错误(从驱动类的歧义转换)?,c++,cocos2d-x-2.x,C++,Cocos2d X 2.x,我正在子类化一个CCSprite,以便为sprite对象做旋转手势 为此,我需要使用CCTargetedTouchDelegate和CCStandardTouchDelegate 但即使在声明了这些委托的函数之后,我也会得到一个模糊错误 错误屏幕截图:- 我的.h文件中的代码。 namespace mygames { class DragSprite: public cocos2d::CCSprite, public cocos2d::CCTargetedTouchDelegate, pub
namespace mygames
{
class DragSprite: public cocos2d::CCSprite, public cocos2d::CCTargetedTouchDelegate, public cocos2d::CCStandardTouchDelegate
{
public:
cocos2d::CCSize canvasSize;
bool init();
static DragSprite* createWithFile(const char *pszFileName);
bool isTouchingOnSprite(cocos2d::CCPoint touch);
virtual bool ccTouchBegan(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent);
virtual void ccTouchMoved(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent);
virtual void ccTouchEnded(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent);
virtual void ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent) ;
virtual void ccTouchesMoved(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent) ;
virtual void ccTouchesEnded(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent) ;
virtual void ccTouchesCancelled(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent) ;
float angleBetweenLineInDegrees(cocos2d::CCPoint startLineA,cocos2d::CCPoint endLineA,cocos2d::CCPoint startLineB,cocos2d::CCPoint endLineB);
~DragSprite();
CREATE_FUNC(DragSprite);
private :
bool isDrag;
bool isPinch;
bool canRotate;
cocos2d::CCPoint whereTouch;
cocos2d::CCPoint midPoint;
int touchNumber;
float lastDistance;
float distance;
float lastAngle;
float angle;
float cumulatedAngle;
float spriteAngle;
float innerRadious;
float outerRadious;
cocos2d::CCArray * touches;
cocos2d::CCTouch *firstTouch;
cocos2d::CCTouch *secondTouch;
float touchDistanceLast;
float touchDistanceNow;
};
}
我的.cpp文件中的错误相关代码
DragSprite* DragSprite::createWithFile(const char *pszFileName)
{
DragSprite *pSprite = new DragSprite();
if (pSprite&&pSprite->initWithFile(pszFileName))
{
cocos2d::CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(pSprite, 0, true);
cocos2d::CCDirector::sharedDirector()->getTouchDispatcher()->addStandardDelegate(pSprite, 0);
pSprite->setAnchorPoint(ccp(0.5, 0.5));
pSprite->autorelease();
return pSprite;
}
CC_SAFE_DELETE(pSprite);
return NULL;
}
bool DragSprite::ccTouchBegan(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent)
{
//some code.....
return false/true;
}
void DragSprite::ccTouchMoved(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent)
{
//Some Code....
}
void DragSprite::ccTouchEnded(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent)
{
//Some Code....
}
void DragSprite::ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent)
{
CCLOG("TSB");
}
void DragSprite::ccTouchesMoved(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent)
{
CCLOG("TSM");
}
void DragSprite::ccTouchesEnded(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent)
{
CCLOG("TSE");
}
void DragSprite::ccTouchesCancelled(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent)
{
CCLOG("TSC");
}
CCTargetedTouchDelegate
和CCStandardTouchDelegate
继承CCTouchDelegate
,这种歧义来自于您有两个该类型的子对象。你为什么两者都用?我似乎没什么道理。@molbdnilo:如果我只使用CCStandardTouchDelegate,它会是一样的吗。i、 e任何精灵上的触摸事件将仅由相关精灵处理?我猜CCTargetedTouchDelegate只能处理特定精灵的事件,即使在一个层中有许多精灵