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.
This commit is contained in:
Pranav Tekchand 2013-04-30 20:47:38 +05:30
parent 31a61072a4
commit 4360c3bff8
1 changed files with 13 additions and 1 deletions

View File

@ -765,6 +765,18 @@ CCRect CCScrollView::getViewRect()
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);
}