Я делаю подклассы CCSprite, чтобы сделать Жест вращения для объекта спрайта.
Для этого мне нужно использовать CCTargetedTouchDelegate и CCStandardTouchDelegate
Но даже после объявления функций этих делегатов я получаю ошибку неоднозначности.
Снимок экрана ошибки: —
код в моем .h файле.
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");
}
Задача ещё не решена.