public GameTouchHandler(GameLayer gameLayer, HexMexCamera hexMexCamera) { GameLayer = gameLayer; HexMexCamera = hexMexCamera; var eventListener = new CCEventListenerTouchOneByOne { IsEnabled = true, OnTouchBegan = OnTouchBegan, OnTouchCancelled = OnTouchCancelled, OnTouchEnded = OnTouchEnded, OnTouchMoved = OnTouchMoved }; gameLayer.AddEventListener(eventListener); }
private void Pintching(CCTouch touch1, CCTouch touch2) { var prevDiff = (touch1.PreviousLocation - touch2.PreviousLocation).Length; var currentDiff = (touch1.Location - touch2.Location).Length; if (currentDiff < MINTOUCHDISTANCE) { return; } var sizeFactor = currentDiff / prevDiff; sizeFactor = sizeFactor - (sizeFactor - 1) / 2; HexMexCamera.SetZoomFactor(sizeFactor * HexMexCamera.ZoomFactor); }
private void Dragging(CCPoint delta) { HexMexCamera.MoveToPosition(HexMexCamera.Position - delta / HexMexCamera.ZoomFactor); }
protected TouchLayer(HexMexCamera hexMexCamera) : base(hexMexCamera) { }