fixed #1495: CCScrollView display area and touch area are wrong if its parent's postion isn't at CCPointZero in world.

This commit is contained in:
James Chen 2012-10-08 14:12:34 +08:00
parent 58b46b2f53
commit cb2f3efc2c
1 changed files with 7 additions and 8 deletions

View File

@ -493,10 +493,10 @@ void CCScrollView::addChild(CCNode * child)
*/ */
void CCScrollView::beforeDraw() void CCScrollView::beforeDraw()
{ {
if (m_bClippingToBounds) if (m_bClippingToBounds)
{ {
// TODO: This scrollview should respect parents' positions // TODO: This scrollview should respect parents' positions
CCPoint screenPos = this->convertToWorldSpace(this->getParent()->getPosition()); CCPoint screenPos = this->getParent()->convertToWorldSpace(this->getPosition());
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);
float s = this->getScale(); float s = this->getScale();
@ -531,8 +531,6 @@ void CCScrollView::visit()
kmGLPushMatrix(); kmGLPushMatrix();
// glPushMatrix();
if (m_pGrid && m_pGrid->isActive()) if (m_pGrid && m_pGrid->isActive())
{ {
m_pGrid->beforeDraw(); m_pGrid->beforeDraw();
@ -584,8 +582,6 @@ void CCScrollView::visit()
} }
kmGLPopMatrix(); kmGLPopMatrix();
// glPopMatrix();
} }
bool CCScrollView::ccTouchBegan(CCTouch* touch, CCEvent* event) bool CCScrollView::ccTouchBegan(CCTouch* touch, CCEvent* event)
@ -595,7 +591,8 @@ bool CCScrollView::ccTouchBegan(CCTouch* touch, CCEvent* event)
return false; return false;
} }
CCRect frame; CCRect frame;
frame = CCRectMake(this->getPosition().x, this->getPosition().y, m_tViewSize.width, m_tViewSize.height); CCPoint frameOriginal = this->getParent()->convertToWorldSpace(this->getPosition());
frame = CCRectMake(frameOriginal.x, frameOriginal.y, m_tViewSize.width, m_tViewSize.height);
//dispatcher does not know about clipping. reject touches outside visible bounds. //dispatcher does not know about clipping. reject touches outside visible bounds.
if (m_pTouches->count() > 2 || if (m_pTouches->count() > 2 ||
@ -645,7 +642,9 @@ void CCScrollView::ccTouchMoved(CCTouch* touch, CCEvent* event)
float newX, newY; float newX, newY;
m_bTouchMoved = true; m_bTouchMoved = true;
frame = CCRectMake(this->getPosition().x, this->getPosition().y, m_tViewSize.width, m_tViewSize.height); CCPoint frameOriginal = this->getParent()->convertToWorldSpace(this->getPosition());
frame = CCRectMake(frameOriginal.x, frameOriginal.y, m_tViewSize.width, m_tViewSize.height);
newPoint = this->convertTouchToNodeSpace((CCTouch*)m_pTouches->objectAtIndex(0)); newPoint = this->convertTouchToNodeSpace((CCTouch*)m_pTouches->objectAtIndex(0));
moveDistance = ccpSub(newPoint, m_tTouchPoint); moveDistance = ccpSub(newPoint, m_tTouchPoint);
m_tTouchPoint = newPoint; m_tTouchPoint = newPoint;