Merge pull request #608 from GMTDev/patch-2

issue #903: Update CCTouch to include the ID/PID of the touch
This commit is contained in:
minggo 2011-12-20 21:48:30 -08:00
commit bb4b1d02bb
3 changed files with 12 additions and 9 deletions

View File

@ -39,19 +39,22 @@ public:
CCPoint locationInView(int nViewId) {CC_UNUSED_PARAM(nViewId); return m_point; }
CCPoint previousLocationInView(int nViewId) {CC_UNUSED_PARAM(nViewId); return m_prevPoint; }
int view() { return m_nViewId; }
int id(){ return m_iID; }
void SetTouchInfo(int nViewId, float x, float y)
void SetTouchInfo(int nViewId, float x, float y, int iID=0)
{
m_nViewId = nViewId;
m_prevPoint = m_point;
m_point.x = x;
m_point.y = y;
m_iID = iID;
}
private:
int m_nViewId;
CCPoint m_point;
CCPoint m_prevPoint;
int m_iID;
};
class CCEvent : public CCObject

View File

@ -59,7 +59,7 @@ static CCTouch *s_pTouches[MAX_TOUCHES] = { NULL };
LOGD("Beginning touches with id: %d, x=%f, y=%f", id, x, y);
pTouch = new CCTouch();
pTouch->SetTouchInfo(0, (x - rcRect.origin.x) / fScreenScaleFactor, (y - rcRect.origin.y) / fScreenScaleFactor);
pTouch->SetTouchInfo(0, (x - rcRect.origin.x) / fScreenScaleFactor, (y - rcRect.origin.y) / fScreenScaleFactor, id);
s_pTouches[id] = pTouch;
set.addObject(pTouch);
@ -83,7 +83,7 @@ static CCTouch *s_pTouches[MAX_TOUCHES] = { NULL };
{
LOGD("Ending touches with id: %d, x=%f, y=%f", id, x, y);
pTouch->SetTouchInfo(0, (x - rcRect.origin.x) / fScreenScaleFactor , (y - rcRect.origin.y) / fScreenScaleFactor);
pTouch->SetTouchInfo(0, (x - rcRect.origin.x) / fScreenScaleFactor , (y - rcRect.origin.y) / fScreenScaleFactor, id);
set.addObject(pTouch);
// release the object
@ -116,7 +116,7 @@ static CCTouch *s_pTouches[MAX_TOUCHES] = { NULL };
if (pTouch)
{
pTouch->SetTouchInfo(0, (x[i] - rcRect.origin.x) / fScreenScaleFactor ,
(y[i] - rcRect.origin.y) / fScreenScaleFactor);
(y[i] - rcRect.origin.y) / fScreenScaleFactor), id[i]);
set.addObject(pTouch);
}
else
@ -149,7 +149,7 @@ static CCTouch *s_pTouches[MAX_TOUCHES] = { NULL };
if (pTouch)
{
pTouch->SetTouchInfo(0, (x[i] - rcRect.origin.x) / fScreenScaleFactor ,
(y[i] - rcRect.origin.y) / fScreenScaleFactor);
(y[i] - rcRect.origin.y) / fScreenScaleFactor, id[i]);
set.addObject(pTouch);
s_pTouches[id[i]] = NULL;
pTouch->release();

View File

@ -413,7 +413,7 @@ static cocos2d::CCTouch *s_pTouches[MAX_TOUCHES];
pTouch = s_pTouches[unUsedIndex] = new cocos2d::CCTouch();
float x = [touch locationInView: [touch view]].x;
float y = [touch locationInView: [touch view]].y;
pTouch->SetTouchInfo(0, x, y);
pTouch->SetTouchInfo(0, x, y, unUsedIndex);
CFDictionaryAddValue(touchesIntergerDict, touch, [NSNumber numberWithInt:unUsedIndex]);
@ -446,7 +446,7 @@ static cocos2d::CCTouch *s_pTouches[MAX_TOUCHES];
float x = [touch locationInView: [touch view]].x;
float y = [touch locationInView: [touch view]].y;
pTouch->SetTouchInfo(0, x, y);
pTouch->SetTouchInfo(0, x, y, pTouch->id());
set.addObject(pTouch);
}
@ -472,7 +472,7 @@ static cocos2d::CCTouch *s_pTouches[MAX_TOUCHES];
float x = [touch locationInView: [touch view]].x;
float y = [touch locationInView: [touch view]].y;
pTouch->SetTouchInfo(0, x, y);
pTouch->SetTouchInfo(0, x, y, pTouch->id());
set.addObject(pTouch);
CFDictionaryRemoveValue(touchesIntergerDict, touch);
@ -502,7 +502,7 @@ static cocos2d::CCTouch *s_pTouches[MAX_TOUCHES];
float x = [touch locationInView: [touch view]].x;
float y = [touch locationInView: [touch view]].y;
pTouch->SetTouchInfo(0, x, y);
pTouch->SetTouchInfo(0, x, y, pTouch->id());
set.addObject(pTouch);
CFDictionaryRemoveValue(touchesIntergerDict, touch);