mirror of https://github.com/axmolengine/axmol.git
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:
commit
bb4b1d02bb
|
@ -39,19 +39,22 @@ public:
|
||||||
CCPoint locationInView(int nViewId) {CC_UNUSED_PARAM(nViewId); return m_point; }
|
CCPoint locationInView(int nViewId) {CC_UNUSED_PARAM(nViewId); return m_point; }
|
||||||
CCPoint previousLocationInView(int nViewId) {CC_UNUSED_PARAM(nViewId); return m_prevPoint; }
|
CCPoint previousLocationInView(int nViewId) {CC_UNUSED_PARAM(nViewId); return m_prevPoint; }
|
||||||
int view() { return m_nViewId; }
|
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_nViewId = nViewId;
|
||||||
m_prevPoint = m_point;
|
m_prevPoint = m_point;
|
||||||
m_point.x = x;
|
m_point.x = x;
|
||||||
m_point.y = y;
|
m_point.y = y;
|
||||||
|
m_iID = iID;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_nViewId;
|
int m_nViewId;
|
||||||
CCPoint m_point;
|
CCPoint m_point;
|
||||||
CCPoint m_prevPoint;
|
CCPoint m_prevPoint;
|
||||||
|
int m_iID;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CCEvent : public CCObject
|
class CCEvent : public CCObject
|
||||||
|
|
|
@ -59,7 +59,7 @@ static CCTouch *s_pTouches[MAX_TOUCHES] = { NULL };
|
||||||
LOGD("Beginning touches with id: %d, x=%f, y=%f", id, x, y);
|
LOGD("Beginning touches with id: %d, x=%f, y=%f", id, x, y);
|
||||||
|
|
||||||
pTouch = new CCTouch();
|
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;
|
s_pTouches[id] = pTouch;
|
||||||
set.addObject(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);
|
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);
|
set.addObject(pTouch);
|
||||||
|
|
||||||
// release the object
|
// release the object
|
||||||
|
@ -116,7 +116,7 @@ static CCTouch *s_pTouches[MAX_TOUCHES] = { NULL };
|
||||||
if (pTouch)
|
if (pTouch)
|
||||||
{
|
{
|
||||||
pTouch->SetTouchInfo(0, (x[i] - rcRect.origin.x) / fScreenScaleFactor ,
|
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);
|
set.addObject(pTouch);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -149,7 +149,7 @@ static CCTouch *s_pTouches[MAX_TOUCHES] = { NULL };
|
||||||
if (pTouch)
|
if (pTouch)
|
||||||
{
|
{
|
||||||
pTouch->SetTouchInfo(0, (x[i] - rcRect.origin.x) / fScreenScaleFactor ,
|
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);
|
set.addObject(pTouch);
|
||||||
s_pTouches[id[i]] = NULL;
|
s_pTouches[id[i]] = NULL;
|
||||||
pTouch->release();
|
pTouch->release();
|
||||||
|
|
|
@ -413,7 +413,7 @@ static cocos2d::CCTouch *s_pTouches[MAX_TOUCHES];
|
||||||
pTouch = s_pTouches[unUsedIndex] = new cocos2d::CCTouch();
|
pTouch = s_pTouches[unUsedIndex] = new cocos2d::CCTouch();
|
||||||
float x = [touch locationInView: [touch view]].x;
|
float x = [touch locationInView: [touch view]].x;
|
||||||
float y = [touch locationInView: [touch view]].y;
|
float y = [touch locationInView: [touch view]].y;
|
||||||
pTouch->SetTouchInfo(0, x, y);
|
pTouch->SetTouchInfo(0, x, y, unUsedIndex);
|
||||||
|
|
||||||
CFDictionaryAddValue(touchesIntergerDict, touch, [NSNumber numberWithInt: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 x = [touch locationInView: [touch view]].x;
|
||||||
float y = [touch locationInView: [touch view]].y;
|
float y = [touch locationInView: [touch view]].y;
|
||||||
pTouch->SetTouchInfo(0, x, y);
|
pTouch->SetTouchInfo(0, x, y, pTouch->id());
|
||||||
|
|
||||||
set.addObject(pTouch);
|
set.addObject(pTouch);
|
||||||
}
|
}
|
||||||
|
@ -472,7 +472,7 @@ static cocos2d::CCTouch *s_pTouches[MAX_TOUCHES];
|
||||||
|
|
||||||
float x = [touch locationInView: [touch view]].x;
|
float x = [touch locationInView: [touch view]].x;
|
||||||
float y = [touch locationInView: [touch view]].y;
|
float y = [touch locationInView: [touch view]].y;
|
||||||
pTouch->SetTouchInfo(0, x, y);
|
pTouch->SetTouchInfo(0, x, y, pTouch->id());
|
||||||
|
|
||||||
set.addObject(pTouch);
|
set.addObject(pTouch);
|
||||||
CFDictionaryRemoveValue(touchesIntergerDict, touch);
|
CFDictionaryRemoveValue(touchesIntergerDict, touch);
|
||||||
|
@ -502,7 +502,7 @@ static cocos2d::CCTouch *s_pTouches[MAX_TOUCHES];
|
||||||
|
|
||||||
float x = [touch locationInView: [touch view]].x;
|
float x = [touch locationInView: [touch view]].x;
|
||||||
float y = [touch locationInView: [touch view]].y;
|
float y = [touch locationInView: [touch view]].y;
|
||||||
pTouch->SetTouchInfo(0, x, y);
|
pTouch->SetTouchInfo(0, x, y, pTouch->id());
|
||||||
|
|
||||||
set.addObject(pTouch);
|
set.addObject(pTouch);
|
||||||
CFDictionaryRemoveValue(touchesIntergerDict, touch);
|
CFDictionaryRemoveValue(touchesIntergerDict, touch);
|
||||||
|
|
Loading…
Reference in New Issue