From 63888a7eb543d9c6e42213fd60f654c5747fbd29 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 20 Aug 2012 10:38:21 +0800 Subject: [PATCH] issue #1432: MutiTouchTest crashes on IOS if putting more than 5 fingers on the screen. --- cocos2dx/platform/CCEGLViewProtocol.cpp | 6 +++--- cocos2dx/platform/ios/EAGLView.mm | 25 +++++++++++++------------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/cocos2dx/platform/CCEGLViewProtocol.cpp b/cocos2dx/platform/CCEGLViewProtocol.cpp index e5afefcbc6..2a9502cdff 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.cpp +++ b/cocos2dx/platform/CCEGLViewProtocol.cpp @@ -188,7 +188,7 @@ void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float // The touches is more than MAX_TOUCHES ? if (nUnusedIndex == -1) { CCLOG("The touches is more than MAX_TOUCHES, nUnusedIndex = %d", nUnusedIndex); - return; + continue; } CCTouch* pTouch = s_pTouches[nUnusedIndex] = new CCTouch(); @@ -235,7 +235,7 @@ void CCEGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float CCInteger* pIndex = (CCInteger*)s_TouchesIntergerDict.objectForKey(id); if (pIndex == NULL) { CCLOG("if the index doesn't exist, it is an error"); - return; + continue; } CCLOGINFO("Moving touches with id: %d, x=%f, y=%f", id, x, y); @@ -284,7 +284,7 @@ void CCEGLViewProtocol::getSetOfTouchesEndOrCancel(CCSet& set, int num, int ids[ if (pIndex == NULL) { CCLOG("if the index doesn't exist, it is an error"); - return; + continue; } /* Add to the set to send to the director */ CCTouch* pTouch = s_pTouches[pIndex->getValue()]; diff --git a/cocos2dx/platform/ios/EAGLView.mm b/cocos2dx/platform/ios/EAGLView.mm index e251b0dde7..693ad31fdf 100755 --- a/cocos2dx/platform/ios/EAGLView.mm +++ b/cocos2dx/platform/ios/EAGLView.mm @@ -73,6 +73,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. #import "CCEGLView.h" //CLASS IMPLEMENTATIONS: +#define IOS_MAX_TOUCHES_COUNT 10 static EAGLView *view = 0; @@ -393,9 +394,9 @@ static EAGLView *view = 0; return; } - int ids[CC_MAX_TOUCHES] = {0}; - float xs[CC_MAX_TOUCHES] = {0.0f}; - float ys[CC_MAX_TOUCHES] = {0.0f}; + int ids[IOS_MAX_TOUCHES_COUNT] = {0}; + float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; + float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; int i = 0; for (UITouch *touch in touches) { @@ -413,9 +414,9 @@ static EAGLView *view = 0; { return; } - int ids[CC_MAX_TOUCHES] = {0}; - float xs[CC_MAX_TOUCHES] = {0.0f}; - float ys[CC_MAX_TOUCHES] = {0.0f}; + int ids[IOS_MAX_TOUCHES_COUNT] = {0}; + float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; + float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; int i = 0; for (UITouch *touch in touches) { @@ -434,9 +435,9 @@ static EAGLView *view = 0; return; } - int ids[CC_MAX_TOUCHES] = {0}; - float xs[CC_MAX_TOUCHES] = {0.0f}; - float ys[CC_MAX_TOUCHES] = {0.0f}; + int ids[IOS_MAX_TOUCHES_COUNT] = {0}; + float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; + float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; int i = 0; for (UITouch *touch in touches) { @@ -455,9 +456,9 @@ static EAGLView *view = 0; return; } - int ids[CC_MAX_TOUCHES] = {0}; - float xs[CC_MAX_TOUCHES] = {0.0f}; - float ys[CC_MAX_TOUCHES] = {0.0f}; + int ids[IOS_MAX_TOUCHES_COUNT] = {0}; + float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; + float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; int i = 0; for (UITouch *touch in touches) {