From 4360c3bff82fdfa00ec749f2e508b5fbe2d99a5f Mon Sep 17 00:00:00 2001 From: Pranav Tekchand Date: Tue, 30 Apr 2013 20:47:38 +0530 Subject: [PATCH] Support negative scaling of CCScrollView. Not checking for it in CCScrollView::getViewRect causes intersectsRect calls (eg: to check if the touch was within the bounds) to return false. --- extensions/GUI/CCScrollView/CCScrollView.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index 0efd2b7498..e2817657e1 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -764,7 +764,19 @@ CCRect CCScrollView::getViewRect() scaleX *= p->getScaleX(); scaleY *= p->getScaleY(); } - + + // Support negative scaling. Not doing so causes intersectsRect calls + // (eg: to check if the touch was within the bounds) to return false. + // Note, CCNode::getScale will assert if X and Y scales are different. + if(scaleX<0.f) { + screenPos.x += m_tViewSize.width*scaleX; + scaleX = -scaleX; + } + if(scaleY<0.f) { + screenPos.y += m_tViewSize.height*scaleY; + scaleY = -scaleY; + } + return CCRectMake(screenPos.x, screenPos.y, m_tViewSize.width*scaleX, m_tViewSize.height*scaleY); }