Browse Source

Copy pointer state when removing old touch ids

Andrey Fidrya 9 years ago
parent
commit
a8a2c86d2e
2 changed files with 13 additions and 7 deletions
  1. 5 1
      oxygine/src/Input.cpp
  2. 8 6
      oxygine/src/PointerState.cpp

+ 5 - 1
oxygine/src/Input.cpp

@@ -44,10 +44,14 @@ namespace oxygine
 			while (i < MAX_TOUCHES - 1) {
 				if ((_ids[i] = _ids[i + 1]) == 0)
 					break;
+				_pointers[i] = _pointers[i + 1];
+				_pointers[i]._index = i + 1;
 				++i;
 			}
-			if (i == MAX_TOUCHES - 1)
+			if (i == MAX_TOUCHES - 1) {
 	            _ids[i] = 0;
+				_pointers[i].init(i + 1);
+			}
         }
     }
 

+ 8 - 6
oxygine/src/PointerState.cpp

@@ -4,14 +4,16 @@ namespace oxygine
 {
     PointerState::PointerState(): _index(0)
     {
-        for (int i = 0; i < MouseButton_Count; ++i)
-            _isPressed[i] = false;
+		init(_index);
     }
 
-    void PointerState::init(int ID)
-    {
-        _index = ID;
-    }
+	void PointerState::init(int pointerIndex)
+	{
+		_index = pointerIndex;
+		for (int i = 0; i < MouseButton_Count; ++i)
+			_isPressed[i] = false;
+		_position.setZero();
+	}
 
     bool isFriend22(Actor* actor, Actor* max_parent, Actor* checkParent)
     {