From 190891bab7ec9a5b56f9fd1c34e3433d58e897f0 Mon Sep 17 00:00:00 2001 From: GavT Date: Tue, 6 Dec 2011 20:06:38 -0800 Subject: [PATCH 1/4] Pass on index/ID/PID of the touch from UITouch to CCTouch and the users touch handlers. Needed for multi touch apps that need to tell which touch/finger was let go. As discussed here by GavT: http://www.cocos2d-x.org/boards/6/topics/4043?r=5751#message-5751 Files Modified: Eagleview.mm, CCTouch.h --- cocos2dx/platform/ios/EAGLView.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2dx/platform/ios/EAGLView.mm b/cocos2dx/platform/ios/EAGLView.mm index b9a9476732..7f2a743929 100755 --- a/cocos2dx/platform/ios/EAGLView.mm +++ b/cocos2dx/platform/ios/EAGLView.mm @@ -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); From 6ab60118afb77d1e37cef7abac1da283ced5057a Mon Sep 17 00:00:00 2001 From: GavT Date: Tue, 6 Dec 2011 20:31:40 -0800 Subject: [PATCH 2/4] Update cocos2dx/include/CCTouch.h --- cocos2dx/include/CCTouch.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos2dx/include/CCTouch.h b/cocos2dx/include/CCTouch.h index 9b52a1657b..a9d1a4c3f8 100755 --- a/cocos2dx/include/CCTouch.h +++ b/cocos2dx/include/CCTouch.h @@ -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) { 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 From 3d86583818226cd45c09d7920a7478878a5210b0 Mon Sep 17 00:00:00 2001 From: GavT Date: Wed, 7 Dec 2011 20:25:51 -0800 Subject: [PATCH 3/4] Update cocos2dx/platform/android/jni/TouchesJni.cpp --- cocos2dx/platform/android/jni/TouchesJni.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2dx/platform/android/jni/TouchesJni.cpp b/cocos2dx/platform/android/jni/TouchesJni.cpp index ca0e0b8425..096312da6c 100644 --- a/cocos2dx/platform/android/jni/TouchesJni.cpp +++ b/cocos2dx/platform/android/jni/TouchesJni.cpp @@ -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(); From 36f8e43dd86dc569371e584687b03589ce1ccad7 Mon Sep 17 00:00:00 2001 From: GavT Date: Tue, 20 Dec 2011 20:40:48 -0800 Subject: [PATCH 4/4] Update cocos2dx/include/CCTouch.h --- cocos2dx/include/CCTouch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/include/CCTouch.h b/cocos2dx/include/CCTouch.h index a9d1a4c3f8..29c40d316c 100755 --- a/cocos2dx/include/CCTouch.h +++ b/cocos2dx/include/CCTouch.h @@ -41,7 +41,7 @@ public: int view() { return m_nViewId; } int id(){ return m_iID; } - void SetTouchInfo(int nViewId, float x, float y, int iID) + void SetTouchInfo(int nViewId, float x, float y, int iID=0) { m_nViewId = nViewId; m_prevPoint = m_point;