2
0
Эх сурвалжийг харах

Fix for Container::isScrolling() so that it won't reset its starting values if the scroll direction changes.

Adam Blake 13 жил өмнө
parent
commit
c75269d12e

+ 10 - 12
gameplay/src/Container.cpp

@@ -37,7 +37,7 @@ Container::Container()
       _scrollBarLeftCap(NULL), _scrollBarHorizontal(NULL), _scrollBarRightCap(NULL),
       _scrollBarLeftCap(NULL), _scrollBarHorizontal(NULL), _scrollBarRightCap(NULL),
       _scroll(SCROLL_NONE), _scrollBarBounds(Rectangle::empty()), _scrollPosition(Vector2::zero()),
       _scroll(SCROLL_NONE), _scrollBarBounds(Rectangle::empty()), _scrollPosition(Vector2::zero()),
       _scrollBarsAutoHide(false), _scrollBarOpacity(1.0f), _scrolling(false),
       _scrollBarsAutoHide(false), _scrollBarOpacity(1.0f), _scrolling(false),
-       _scrollingFirstX(0), _scrollingFirstY(0), _scrollingLastX(0), _scrollingLastY(0),
+      _scrollingVeryFirstX(0), _scrollingVeryFirstY(0), _scrollingFirstX(0), _scrollingFirstY(0), _scrollingLastX(0), _scrollingLastY(0),
       _scrollingStartTimeX(0), _scrollingStartTimeY(0), _scrollingLastTime(0),
       _scrollingStartTimeX(0), _scrollingStartTimeY(0), _scrollingLastTime(0),
       _scrollingVelocity(Vector2::zero()), _scrollingFriction(1.0f),
       _scrollingVelocity(Vector2::zero()), _scrollingFriction(1.0f),
       _scrollingRight(false), _scrollingDown(false),
       _scrollingRight(false), _scrollingDown(false),
@@ -369,8 +369,8 @@ bool Container::isScrolling() const
         return true;
         return true;
 
 
     return (_scrolling &&
     return (_scrolling &&
-            (abs(_scrollingLastX - _scrollingFirstX) > SCROLL_THRESHOLD ||
-             abs(_scrollingLastY - _scrollingFirstY) > SCROLL_THRESHOLD));
+            (abs(_scrollingLastX - _scrollingVeryFirstX) > SCROLL_THRESHOLD ||
+             abs(_scrollingLastY - _scrollingVeryFirstY) > SCROLL_THRESHOLD));
 }
 }
 
 
 Animation* Container::getAnimation(const char* id) const
 Animation* Container::getAnimation(const char* id) const
@@ -804,8 +804,8 @@ bool Container::touchEventScroll(Touch::TouchEvent evt, int x, int y, unsigned i
         {
         {
             _contactIndex = (int) contactIndex;
             _contactIndex = (int) contactIndex;
             _contactIndices++;
             _contactIndices++;
-            _scrollingLastX = _scrollingFirstX = x;
-            _scrollingLastY = _scrollingFirstY = y;
+            _scrollingLastX = _scrollingFirstX = _scrollingVeryFirstX = x;
+            _scrollingLastY = _scrollingFirstY = _scrollingVeryFirstY = y;
             _scrollingVelocity.set(0, 0);
             _scrollingVelocity.set(0, 0);
             _scrolling = true;
             _scrolling = true;
             _scrollingStartTimeX = _scrollingStartTimeY = 0;
             _scrollingStartTimeX = _scrollingStartTimeY = 0;
@@ -1108,13 +1108,11 @@ bool Container::pointerEvent(bool mouse, char evt, int x, int y, int data)
         }
         }
         break;
         break;
     case Touch::TOUCH_RELEASE:
     case Touch::TOUCH_RELEASE:
-        {
-            if (eventConsumed)
-            {
-                if (_contactIndices > 0)
-                    _contactIndices--;
-            }
-        }
+		if (eventConsumed)
+		{
+			if (_contactIndices > 0)
+				_contactIndices--;
+		}
         break;
         break;
     }
     }
 
 

+ 10 - 2
gameplay/src/Container.h

@@ -444,11 +444,19 @@ protected:
      */
      */
     bool _scrolling;
     bool _scrolling;
     /** 
     /** 
-     * First scrolling touch x position
+	 * First scrolling touch x position
+	 */
+	int _scrollingVeryFirstX;
+	/**
+	 * First scrolling touch y position
+	 */
+	int _scrollingVeryFirstY;
+    /**
+     * First scrolling touch x position since last change in direction.
      */ 
      */ 
     int _scrollingFirstX;
     int _scrollingFirstX;
     /** 
     /** 
-     * First scrolling touch y position
+     * First scrolling touch y position since last change in direction.
      */ 
      */ 
     int _scrollingFirstY;
     int _scrollingFirstY;
     /** 
     /**