private protected void OnTouchesMovedDoAccounting(List <CCTouch> touches, CCEvent touchEvent) { foreach (var touch in touches) { if (ActiveTouches.ContainsKey(touch)) { ActiveTouches[touch] = touch.Location; //Console.WriteLine("touch "+touch.Id+" location updated: " + touch.Location); } } }
/// <summary> /// Updates tracked touches and stores the rest /// </summary> private void UpdateTouches() { NewTouches.Clear(); foreach (var touch in Input.touches) { if (ActiveTouches.ContainsKey(touch.fingerId)) { CheckTouchFlags(touch); ActiveTouches[touch.fingerId] = touch; } else { ActiveTouches[touch.fingerId] = touch; ActiveTouchFlags[touch.fingerId] = new TouchFlags(); ActiveTouchOrigins[touch.fingerId] = touch.position; NewTouches.Add(touch); } } }
private protected void OnTouchesBeganDoAccounting(List <CCTouch> touches, CCEvent touchEvent) { foreach (var touch in touches) { if (!ActiveTouches.ContainsKey(touch)) { //Console.WriteLine("TOUCH ADDED, ID: " + touch.Id); ActiveTouches.Add(touch, touch.Location); } } if (touches.Count > 0) { TouchCount += touches.Count; // intercept all additional touches (don't allow a second touch) if (TouchCount > 1) { touchEvent.StopPropogation(); } } }
private protected void OnTouchesEndedDoAccounting(List <CCTouch> touches, CCEvent touchEvent) { foreach (var touch in touches) { ActiveTouches.Remove(touch); //Console.WriteLine("TOUCH REMOVED, ID: " + touch.Id); //Console.WriteLine("ActiveTouches.Count: " + ActiveTouches.Count); } if (touches.Count > 0) { TouchCount -= touches.Count; if (TouchCount < 0) { TouchCount = 0; } touchEvent.IsStopped = false; // workaround for a bug that is created by the swallowing of a touchMoved-event in UIElement(Node) // intercept the event if there are touches remaining (i.e. only the last release will be the "real" release) if (TouchCount > 0) { touchEvent.StopPropogation(); } //Console.WriteLine("TouchCount: " + TouchCount); } }
/// <summary> /// Removes given <see cref="Touch"/> from active touches /// </summary> /// <param name="touch"><see cref="Touch"/> to be unregistered</param> internal void UnregisterTouch(Touch touch) { ActiveTouches.Remove(touch.fingerId); ActiveTouchFlags.Remove(touch.fingerId); }