コード例 #1
0
ファイル: Box2DView.cs プロジェクト: h7ing/CocosSharp
		void onTouchMoved(CCTouch touch, CCEvent touchEvent)
        {
            CCPoint touchLocation = touch.Location;
            CCPoint nodePosition = ConvertToNodeSpace(touchLocation);

            m_test.MouseMove(new Vector2(nodePosition.X, nodePosition.Y));
        }
コード例 #2
0
ファイル: ClickAndMoveTest.cs プロジェクト: h7ing/CocosSharp
		void onTouchesEnded(List<CCTouch> touches, CCEvent touchEvent)
        {
            //base.ccTouchesEnded(touches, event_);
            object it = touches.First();
            CCTouch touch = (CCTouch)(it);

            var convertedLocation = touch.Location;

            CCNode s = this[ClickAndMoveTest.kTagSprite];
            s.StopAllActions();
            s.RunAction(new CCMoveTo (1, new CCPoint(convertedLocation.X, convertedLocation.Y)));
            float o = convertedLocation.X - s.Position.X;
            float a = convertedLocation.Y - s.Position.Y;
            float at = (float)(Math.Atan(o / a) * 57.29577951f);

            if (a < 0)
            {
                if (o < 0)
                    at = 180 + Math.Abs(at);
                else
                    at = 180 - Math.Abs(at);
            }

            s.RunAction(new CCRotateTo (1, at));
        }
コード例 #3
0
 void OnTouchesEnded(List<CCTouch> touches, CCEvent touchEvent)
 {
     if (touches.Count > 0)
     {
         // Perform touch handling here
     }
 }
コード例 #4
0
        void OnTouchesEnded(List<CCTouch> touches, CCEvent touchEvent)
        {
            if (touches.Count > 0)
            {

            }
        }
コード例 #5
0
 void OnTouchEnded(CCTouch  touch, CCEvent  touchEvent)
 {
     bool hits = touchHits(touch);
     if (hits && Triggered != null)
         Triggered(this, EventArgs.Empty);
     scaleButtonTo(1);
 }
コード例 #6
0
        void HandleTouchesMoved(System.Collections.Generic.List<CCTouch> touches, CCEvent touchEvent)
        {
            // we only care about the first touch:
            var locationOnScreen = touches [0].Location;

            paddleSprite.PositionX = locationOnScreen.X;
        }
コード例 #7
0
ファイル: IntroLayer.cs プロジェクト: netonjm/RubeLoader
        public void OnTouchesBegan(List<CCTouch> touches, CCEvent touchEvent)
        {
            CCTouch touch = touches.FirstOrDefault();
            CCPoint location = touch.Location;

            List<CCPhysicsShape> shapes = Scene.PhysicsWorld.GetShapes(location);

            CCPhysicsBody body = null;

            foreach (var obj in shapes)
            {
                if ((obj.Body.Tag & DRAG_BODYS_TAG) != 0)
                {
                    body = obj.Body;
                    break;
                }
            }

            if (body != null)
            {
                CCNode mouse = new CCNode();

                mouse.PhysicsBody = new CCPhysicsBody();
                mouse.PhysicsBody.IsDynamic = false;
                mouse.Position = location;
                AddChild(mouse);

                CCPhysicsJointPin join = CCPhysicsJointPin.Construct(mouse.PhysicsBody, body, location);
                join.SetMaxForce(5000 * body.GetMass());
                Scene.PhysicsWorld.AddJoint(join);
                mouses.Add(touch.Id, mouse);

            }
        }
コード例 #8
0
ファイル: Box2DView.cs プロジェクト: h7ing/CocosSharp
		void onTouchMoved(CCTouch touch, CCEvent touchEvent)
        {
            CCPoint touchLocation = touch.LocationOnScreen;
            CCPoint nodePosition = Layer.ScreenToWorldspace(touchLocation);

            m_test.MouseMove(new b2Vec2(nodePosition.X, nodePosition.Y));
        }
 public void OnTouchesEnded(List<CCTouch> touches, CCEvent e)
 {
     if (!win)
     {
         foreach (CCTouch touch in touches)
         {
             for (int i = 0; i < botones.Length; i++)
             {
                 if (GameData.CheckIfSpriteTouched(touch, botones[i]))
                 {
                     if (llamando == i + 1  && jugadoresActivos[i])
                     {
                         debug.Text = "Correcto!";
                         debug.Color = GetColorJugador(i + 1);
                         contesto = true;
                         CCSimpleAudioEngine.SharedEngine.PlayEffect("sounds/coin");
                     }
                     else
                     {
                         DerrotaJugador(i + 1);
                     }
                 }
             }
         }
     }
     else {
         ReturnToMenu();
     }
 }
コード例 #10
0
ファイル: StartScene.cs プロジェクト: Nuckal777/mapKnight
 private void HandleTouchesEnded(System.Collections.Generic.List<CCTouch> touches, CCEvent touchEvent)
 {
     foreach (CCTouch Touch in touches) {
         if (startGame != null) {
             startGame ();
         }
     }
 }
コード例 #11
0
            bool OnTouchBegan(CCTouch touch, CCEvent touchEvent)
            {
                bool hits = touchHits(touch);
                if (hits)
                    scaleButtonTo(0.9f);

                return hits;
            }
コード例 #12
0
ファイル: Paddle.cs プロジェクト: netonjm/CocosSharp
		bool onTouchBegan(CCTouch touch, CCEvent touchEvent)
        {
            if (m_state != PaddleState.kPaddleStateUngrabbed) return false;
            if (!containsTouchLocation(touch)) return false;

            m_state = PaddleState.kPaddleStateGrabbed;
            return true;
        }
コード例 #13
0
		void onTouchesEnded(List<CCTouch> pTouches, CCEvent touchEvent)
        {
            drag = false;
            snapArrowsToEdge();

            arrowsBar.Visible = false;
            UpdateLineHeight();
        }
コード例 #14
0
ファイル: DebugLayer.cs プロジェクト: Lopt/ascendancy
 /// <summary>
 /// If the touch is ended return the visbility of this layer and reverse it.
 /// </summary>
 /// <returns><c>true</c> if this layer is visible; otherwise, <c>false</c>.</returns>
 /// <param name="touches">The touches list.</param>
 /// <param name="touchEvent">The touch event.</param>
 public bool OnTouchesEnded(List<CCTouch> touches, CCEvent touchEvent)
 {
     if (Visible)
     {
         Visible = !Visible;
         return true;
     }
     return false;
 }
コード例 #15
0
ファイル: BugsTestMainLayer.cs プロジェクト: h7ing/CocosSharp
		void onTouchesBegan(List<CCTouch> touches, CCEvent touchEvent)
        {
			foreach (var it in touches)
            {
                CCTouch touch = it;
                var m_tBeginPos = touch.LocationOnScreen;
            }

        }
コード例 #16
0
ファイル: DragSprite.cs プロジェクト: AndyDentFree/xfcs-play
 public void OnTouchesEnded(List<CCTouch> touches, CCEvent touchEvent)
 {
     foreach (CCTouch touch in touches) {
         if (touch == Touch) {
             Touch = null;
             return;
         }
     }
 }
コード例 #17
0
ファイル: Parallax2.cs プロジェクト: KevinHeyer/CocosSharp
		void onTouchesMoved(List<CCTouch> touches, CCEvent touchEvent)
        {

			var diff = touches[0].Delta;

			var node = GetChildByTag((int)KTag.kTagNode);
			var currentPos = node.Position;
			node.Position = currentPos + diff;
        }
コード例 #18
0
 void TouchCancelled(CCTouch touch, CCEvent touchEvent)
 {
     Debug.Assert(MenuState == CCMenuState.TrackingTouch, "[Menu ccTouchCancelled] -- invalid state");
     if (SelectedMenuItem != null)
     {
         SelectedMenuItem.Selected = false;
     }
     MenuState = CCMenuState.Waiting;
 }
コード例 #19
0
ファイル: DragSprite.cs プロジェクト: AndyDentFree/xfcs-play
 public void OnTouchesMoved(List<CCTouch> touches, CCEvent touchEvent)
 {
     foreach (CCTouch touch in touches) {
         if (touch == Touch) {
             PositionX = touch.Location.X;
             PositionY = touch.Location.Y;
         }
     }
 }
コード例 #20
0
 //Handle all touches for this scene
 void handleEndTouches(System.Collections.Generic.List<CCTouch> touches, CCEvent touchEvent)
 {
     var touchLocation = touches[0].Location;
     //If play is hit
     if (play.BoundingBoxTransformedToWorld.ContainsPoint(touchLocation))
         GameLayer.getNewMap(GameView);
     //If quit is hit
     else if (quit.BoundingBoxTransformedToWorld.ContainsPoint(touchLocation))
         Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
 }
コード例 #21
0
ファイル: Box2DView.cs プロジェクト: KevinHeyer/CocosSharp
		bool onTouchBegan(CCTouch touch, CCEvent touchEvent)
        {
            CCPoint touchLocation = touch.LocationOnScreen;

            CCPoint nodePosition = Layer.ScreenToWorldspace(touchLocation);
            //    NSLog(@"pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y);
            CCLog.Log("OnTouchBegan: " + nodePosition);
			return m_test.MouseDown(new b2Vec2(nodePosition.X, nodePosition.Y));

        }
コード例 #22
0
		private void HandleTouchesBegan(List<CCTouch> touches, CCEvent touchEvent)
		{
			foreach (var item in touches)
			{
				if (item.Location.X > owner.ContentSize.Center.X)
				{
					touchedOnRightSide = true;
				}
			}
		}
コード例 #23
0
ファイル: Ship.cs プロジェクト: CHANDAN145/monodroid-samples
        private void HandleInput(System.Collections.Generic.List<CCTouch> touches, CCEvent touchEvent)
        {
            if(touches.Count > 0)
            {
                CCTouch firstTouch = touches[0];

                this.PositionX = firstTouch.Location.X;
                this.PositionY = firstTouch.Location.Y;
            }
        }
コード例 #24
0
ファイル: MultiTouchTest.cs プロジェクト: netonjm/CocosSharp
		void onTouchesEnded(List<CCTouch> touches, CCEvent touchEvent)
        {
            foreach (var item in touches )
            {
                CCTouch touch = item;
                TouchPoint pTP = s_dic[touch.Id];
                RemoveChild(pTP, true);
                s_dic.Remove(touch.Id);
            }
        }
コード例 #25
0
ファイル: MultiTouchTest.cs プロジェクト: netonjm/CocosSharp
		void onTouchesMoved(List<CCTouch> touches, CCEvent touchEvent)
        {
            foreach(var item in touches)
            {
                CCTouch touch = item;
                TouchPoint pTP = s_dic[touch.Id];
                CCPoint location = touch.LocationOnScreen;
                pTP.SetTouchPos(location);
            }
        }
コード例 #26
0
        void OnTouchMoved(CCTouch pTouch, CCEvent touchEvent)
        {
            CCPoint location = LocationFromTouch(pTouch);

            location = new CCPoint(location.X - initialTouchXPosition, 0);

            HasMoved = true;

            switchSprite.SliderXPosition = location.X;
        }
コード例 #27
0
		void onTouchesBegan(List<CCTouch> pTouches, CCEvent touchEvent)
        {
            CCTouch touch = pTouches[0];
            CCPoint location = touch.Location;

            if (arrows.BoundingBox.ContainsPoint(location))
            {
                drag = true;
                arrowsBar.Visible = true;
            }
        }
コード例 #28
0
ファイル: Box2DView.cs プロジェクト: h7ing/CocosSharp
		bool onTouchBegan(CCTouch touch, CCEvent touchEvent)
        {
            CCPoint touchLocation = touch.Location;

            CCPoint nodePosition = ConvertToNodeSpace(touchLocation);
            //    NSLog(@"pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y);

            m_test.MouseDown(new Vector2(nodePosition.X, nodePosition.Y));

            return true;
        }
コード例 #29
0
        void OnTouchMoved(CCTouch pTouch, CCEvent touchEvent)
        {
            // Get the touch location
            CCPoint touchLocation = GetTouchLocation(pTouch);

            //small modification: this allows changing of the colour, even if the touch leaves the bounding area
            //     UpdateSliderPosition(touchLocation);
            //     sendActionsForControlEvents(ControlEventValueChanged);
            // Check the touch position on the Slider
            CheckSliderPosition(touchLocation);
        }
コード例 #30
0
ファイル: DragSprite.cs プロジェクト: AndyDentFree/xfcs-play
 public void OnTouchesBegan(List<CCTouch> touches, CCEvent touchEvent)
 {
     foreach (CCTouch touch in touches) {
         if (touch!=null) {
             // AirHockey uses layer.ScreenToWorldspace(touch.LocationOnScreen)
             if (BoundingBox.ContainsPoint(touch.Location)) {
                 Touch = touch;
                 return;
             }
         }
     }
 }
コード例 #31
0
        bool OnTouchBegan(CCTouch touch, CCEvent touchEvent)
        {
            if (!IsTouchInside(touch) || !Enabled || !Visible)
            {
                return(false);
            }

            CCPoint location = LocationFromTouch(touch);

            SliderBegan(location);
            return(true);
        }
コード例 #32
0
        bool OnTouchBegan(CCTouch touch, CCEvent touchEvent)
        {
            if (!IsTouchInside(touch) || !Enabled || !Visible)
            {
                return(false);
            }

            previousLocation = GetTouchLocation(touch);

            PotentiometerBegan(previousLocation);

            return(true);
        }
コード例 #33
0
        //events
        bool onTouchBegan(CCTouch pTouch, CCEvent touchEvent)
        {
            if (!IsTouchInside(pTouch) || !Enabled)
            {
                return(false);
            }

            State       = CCControlState.Highlighted;
            isPushed    = true;
            Highlighted = true;
            SendActionsForControlEvents(CCControlEvent.TouchDown);
            return(true);
        }
コード例 #34
0
        bool OnTouchBegan(CCTouch touch, CCEvent touchEvent)
        {
            if (!Enabled || !Visible)
            {
                return(false);
            }

            // Get the touch location
            CCPoint touchLocation = GetTouchLocation(touch);

            // Check the touch position on the Slider
            return(CheckSliderPosition(touchLocation));
        }
コード例 #35
0
ファイル: LayerGradient.cs プロジェクト: h7ing/CocosSharp
		void onTouchesMoved(List<CCTouch> touches, CCEvent touchEvent)
        {
            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            var it = touches.FirstOrDefault();
            CCTouch touch = (CCTouch)(it);
            var start = touch.LocationOnScreen;

            CCPoint diff = new CCPoint(s.Width / 2 - start.X, s.Height / 2 - start.Y);
            diff = CCPoint.Normalize(diff);

            gradientLayer.Vector = diff;
        }
コード例 #36
0
ファイル: CCScrollView.cs プロジェクト: zhuruvl/CocosSharp
 public virtual void TouchCancelled(CCTouch touch, CCEvent touchEvent)
 {
     if (!Visible)
     {
         return;
     }
     touches.Remove(touch);
     if (touches.Count == 0)
     {
         Dragging     = false;
         IsTouchMoved = false;
     }
 }
コード例 #37
0
ファイル: MultiTouchTest.cs プロジェクト: h7ing/CocosSharp
		void onTouchesBegan(List<CCTouch> touches, CCEvent touchEvent)
        {
            foreach (var item in touches)
            {
                CCTouch touch = (item);
                TouchPoint touchPoint = TouchPoint.TouchPointWithParent(this);
                CCPoint location = touch.Location;
                touchPoint.SetTouchPos(location);
                touchPoint.SetTouchColor(s_TouchColors[touch.Id % 5]);

                AddChild(touchPoint);
                s_dic.Add( touch.Id, touchPoint);
            }
        }
コード例 #38
0
        void OnTouchesEnded(List<CCTouch> touches, CCEvent touchEvent)
        {
            foreach (CCTouch item in touches)
            {
                if (item == null)
                {
                    break;
                }

                var location = Layer.ScreenToWorldspace(item.LocationOnScreen);

                AddNewSpriteWithCoords(location);
            }
        }
コード例 #39
0
        void OnTouchCancelled(CCTouch pTouch, CCEvent touchEvent)
        {
            CCPoint location = LocationFromTouch(pTouch);

            switchSprite.ThumbSprite.Color = new CCColor3B(255, 255, 255);

            if (HasMoved)
            {
                On = !(location.X < switchSprite.ContentSize.Width / 2);
            }
            else
            {
                On = !on;
            }
        }
コード例 #40
0
        ///** Updates all listeners
        // *  1) Removes all listener items that have been marked as 'removed' when dispatching event.
        // *  2) Adds all listener items that have been marked as 'added' when dispatching event.
        // */
        void UpdateListeners(CCEvent forEvent)
        {
            Debug.Assert(inDispatch > 0, "If program goes here, there should be events to dispatch.");

            if (forEvent.Type == CCEventType.TOUCH)
            {
                UpdateListeners(CCEventListenerTouchOneByOne.LISTENER_ID);
                UpdateListeners(CCEventListenerTouchAllAtOnce.LISTENER_ID);
            }
            else
            {
                UpdateListeners(CCEventDispatcher.GetListenerID(forEvent));
            }

            if (inDispatch > 1)
            {
                return;
            }

            Debug.Assert(inDispatch == 1, "_inDispatch should be 1 here.");


            List <string> lmKeysToRemove = new List <string>();

            foreach (string lv in listenerMap.Keys)
            {
                if (listenerMap[lv].IsEmpty)
                {
                    lmKeysToRemove.Add(lv);
                }
            }

            foreach (string key in lmKeysToRemove)
            {
                priorityDirtyFlagMap.Remove(key);
                listenerMap[key] = null;
                listenerMap.Remove(key);
            }

            if (toBeAddedListeners.Count > 0)
            {
                foreach (var listener in toBeAddedListeners)
                {
                    ForceAddEventListener(listener);
                }
                toBeAddedListeners.Clear();
            }
        }
コード例 #41
0
        void OnTouchEnded(CCTouch pTouch, CCEvent touchEvent)
        {
            MinusSprite.Color = CCColor3B.White;
            PlusSprite.Color  = CCColor3B.White;

            if (autorepeat)
            {
                StopAutorepeat();
            }

            if (IsTouchInside(pTouch))
            {
                CCPoint location = GetTouchLocation(pTouch);

                Value = this.value + ((location.X < MinusSprite.ContentSize.Width) ? (0.0f - stepValue) : stepValue);
            }
        }
コード例 #42
0
        bool OnTouchBegan(CCTouch touch, CCEvent touchEvent)
        {
            if (!IsTouchInside(touch) || !Enabled)
            {
                return(false);
            }

            HasMoved = false;

            CCPoint location = LocationFromTouch(touch);

            initialTouchXPosition = location.X - switchSprite.SliderXPosition;

            switchSprite.ThumbSprite.Color = new CCColor3B(166, 166, 166);
            switchSprite.NeedsLayout();

            return(true);
        }
コード例 #43
0
        void onTouchEnded(CCTouch pTouch, CCEvent touchEvent)
        {
            if (m_pTrackNode == null)
            {
                return;
            }

            var endPos = pTouch.LocationOnScreen;

            if (m_pTrackNode.BoundingBox.ContainsPoint(m_beginPos) && m_pTrackNode.BoundingBox.ContainsPoint(endPos))
            {
                onClickTrackNode(true);
            }
            else
            {
                onClickTrackNode(false);
            }
        }
コード例 #44
0
        void onTouchEnded(CCTouch pTouch, CCEvent touchEvent)
        {
            State       = CCControlState.Normal;
            isPushed    = false;
            Highlighted = false;


            if (IsTouchInside(pTouch))
            {
                if (Clicked != null)
                {
                    OnClicked();
                }
                OnTouchUpInside();
            }
            else
            {
                OnTouchUpOutside();
            }
        }
コード例 #45
0
        void onTouchEnded(CCTouch pTouch, CCEvent touchEvent)
        {
            State       = CCControlState.Normal;
            isPushed    = false;
            Highlighted = false;


            if (IsTouchInside(pTouch))
            {
                if (OnButtonTap != null)
                {
                    OnButtonTap(this);
                }
                SendActionsForControlEvents(CCControlEvent.TouchUpInside);
            }
            else
            {
                SendActionsForControlEvents(CCControlEvent.TouchUpOutside);
            }
        }
コード例 #46
0
        bool OnTouchBegan(CCTouch pTouch, CCEvent touchEvent)
        {
            if (!IsTouchInside(pTouch) || !Enabled || !Visible)
            {
                return(false);
            }

            CCPoint location = GetTouchLocation(pTouch);

            UpdateLayoutUsingTouchLocation(location);

            touchInsideFlag = true;

            if (autorepeat)
            {
                StartAutorepeat();
            }

            return(true);
        }
コード例 #47
0
ファイル: CCMenu.cs プロジェクト: ztaksoftware/CocosSharp
        void TouchMoved(CCTouch touch, CCEvent touchEvent)
        {
            Debug.Assert(MenuState == CCMenuState.TrackingTouch, "[Menu TouchMoved] -- invalid state");
            CCMenuItem currentItem = ItemForTouch(touch);

            if (currentItem != SelectedMenuItem)
            {
                if (SelectedMenuItem != null)
                {
                    SelectedMenuItem.Selected = false;
                }

                if (currentItem != null)
                {
                    currentItem.Selected = true;
                }

                SelectedMenuItem = currentItem;
            }
        }
コード例 #48
0
        static string GetListenerID(CCEvent listenerEvent)
        {
            string ret = string.Empty;

            switch (listenerEvent.Type)
            {
            case CCEventType.ACCELERATION:
                ret = CCEventListenerAccelerometer.LISTENER_ID;
                break;

            case CCEventType.CUSTOM:
                var customEvent = (CCEventCustom)(listenerEvent);
                ret = customEvent.EventName;
                break;

            case CCEventType.KEYBOARD:
                ret = CCEventListenerKeyboard.LISTENER_ID;
                break;

            case CCEventType.MOUSE:
                ret = CCEventListenerMouse.LISTENER_ID;
                break;

            case CCEventType.GAMEPAD:
                ret = CCEventListenerGamePad.LISTENER_ID;
                break;

            case CCEventType.TOUCH:
                // Touch listener is very special, it contains two kinds of listeners, EventListenerTouchOneByOne and EventListenerTouchAllAtOnce.
                // return UNKNOWN instead.
                Debug.Assert(false, "Don't call this method if the event is for touch.");
                break;

            default:
                Debug.Assert(false, "Invalid type!");
                break;
            }

            return(ret);
        }
コード例 #49
0
        /// <summary>
        /// Dispatches the event
        /// Also removes all EventListeners marked for deletion from the event dispatcher list.
        /// </summary>
        /// <param name="eventToDispatch"></param>
        public void DispatchEvent(CCEvent eventToDispatch)
        {
            if (!IsEnabled)
            {
                return;
            }

            UpdateDirtyFlagForSceneGraph();

            inDispatch++;

            if (eventToDispatch.Type == CCEventType.TOUCH)
            {
                DispatchTouchEvent((CCEventTouch)eventToDispatch);
                inDispatch--;
                return;
            }


            var listenerID = CCEventDispatcher.GetListenerID(eventToDispatch);

            SortEventListeners(listenerID);

            if (listenerMap.ContainsKey(listenerID))
            {
                var listeners = listenerMap [listenerID];

                Func <CCEventListener, bool> onEvent = delegate(CCEventListener listener)
                {
                    eventToDispatch.CurrentTarget = listener.SceneGraphPriority;
                    listener.OnEvent(eventToDispatch);
                    return(eventToDispatch.IsStopped);
                };

                DispatchEventToListeners(listeners, onEvent);
            }

            UpdateListeners(eventToDispatch);
            inDispatch--;
        }
コード例 #50
0
ファイル: CCScrollView.cs プロジェクト: zhuruvl/CocosSharp
        /** override functions */
        public virtual bool TouchBegan(CCTouch pTouch, CCEvent touchEvent)
        {
            if (!Visible)
            {
                return(false);
            }

            var frame = ViewRect;

            //dispatcher does not know about clipping. reject touches outside visible bounds.
            if (touches.Count > 2 ||
                IsTouchMoved ||
                !frame.ContainsPoint(container.Layer.ScreenToWorldspace(pTouch.LocationOnScreen)))
            {
                return(false);
            }

            if (!touches.Contains(pTouch))
            {
                touches.Add(pTouch);
            }

            if (touches.Count == 1)
            {
                // scrolling
                touchPoint     = Layer.ScreenToWorldspace(pTouch.LocationOnScreen);
                IsTouchMoved   = false;
                Dragging       = true; //Dragging started
                scrollDistance = CCPoint.Zero;
                touchLength    = 0.0f;
            }
            else if (touches.Count == 2)
            {
                touchPoint  = CCPoint.Midpoint(Layer.ScreenToWorldspace(touches[0].LocationOnScreen), Layer.ScreenToWorldspace(touches[1].LocationOnScreen));
                touchLength = CCPoint.Distance(container.Layer.ScreenToWorldspace(touches[0].LocationOnScreen), container.Layer.ScreenToWorldspace(touches[1].LocationOnScreen));
                Dragging    = false;
            }
            return(true);
        }
コード例 #51
0
ファイル: CCScrollView.cs プロジェクト: zhuruvl/CocosSharp
        public virtual void TouchEnded(CCTouch touch, CCEvent touchEvent)
        {
            if (!Visible)
            {
                return;
            }

            if (touches.Contains(touch))
            {
                if (touches.Count == 1 && IsTouchMoved)
                {
                    Schedule(DeaccelerateScrolling);
                }
                touches.Remove(touch);
            }

            if (touches.Count == 0)
            {
                Dragging     = false;
                IsTouchMoved = false;
            }
        }
コード例 #52
0
ファイル: CCMenu.cs プロジェクト: ztaksoftware/CocosSharp
        bool TouchBegan(CCTouch touch, CCEvent touchEvent)
        {
            if (MenuState != CCMenuState.Waiting || !Visible || !Enabled)
            {
                return(false);
            }

            for (CCNode c = Parent; c != null; c = c.Parent)
            {
                if (c.Visible == false)
                {
                    return(false);
                }
            }

            SelectedMenuItem = ItemForTouch(touch);
            if (SelectedMenuItem != null)
            {
                MenuState = CCMenuState.TrackingTouch;
                SelectedMenuItem.Selected = true;
                return(true);
            }
            return(false);
        }
コード例 #53
0
 void OnTouchEnded(CCTouch pTouch, CCEvent touchEvent)
 {
     SliderEnded(CCPoint.Zero);
 }
コード例 #54
0
 bool onTouchBegan(CCTouch pTouch, CCEvent touchEvent)
 {
     m_beginPos = pTouch.LocationOnScreen;
     return(true);
 }
コード例 #55
0
        void OnTouchMoved(CCTouch touch, CCEvent touchEvent)
        {
            CCPoint location = GetTouchLocation(touch);

            PotentiometerMoved(location);
        }
コード例 #56
0
 bool OnTouchBegan(CCTouch touch, CCEvent touchEvent)
 {
     return(false);
 }
コード例 #57
0
ファイル: CCScrollView.cs プロジェクト: zhuruvl/CocosSharp
        public virtual void TouchMoved(CCTouch touch, CCEvent touchEvent)
        {
            if (!Visible)
            {
                return;
            }

            if (touches.Contains(touch))
            {
                if (touches.Count == 1 && Dragging)
                {                                   // scrolling
                    CCPoint moveDistance, newPoint; //, maxInset, minInset;
                    float   newX, newY;

                    var frame = ViewRect;

                    newPoint     = Layer.ScreenToWorldspace(touches[0].LocationOnScreen);
                    moveDistance = newPoint - touchPoint;

                    float dis = 0.0f;
                    if (Direction == CCScrollViewDirection.Vertical)
                    {
                        dis = moveDistance.Y;
                    }
                    else if (Direction == CCScrollViewDirection.Horizontal)
                    {
                        dis = moveDistance.X;
                    }
                    else
                    {
                        dis = (float)Math.Sqrt(moveDistance.X * moveDistance.X + moveDistance.Y * moveDistance.Y);
                    }

                    if (!IsTouchMoved && Math.Abs(ConvertDistanceFromPointToInch(dis)) < MOVE_INCH)
                    {
                        //CCLOG("Invalid movement, distance = [%f, %f], disInch = %f", moveDistance.x, moveDistance.y);
                        return;
                    }

                    if (!IsTouchMoved)
                    {
                        moveDistance = CCPoint.Zero;
                    }

                    touchPoint   = newPoint;
                    IsTouchMoved = true;

                    if (frame.ContainsPoint(touchPoint))
                    {
                        switch (Direction)
                        {
                        case CCScrollViewDirection.Vertical:
                            moveDistance = new CCPoint(0.0f, moveDistance.Y);
                            break;

                        case CCScrollViewDirection.Horizontal:
                            moveDistance = new CCPoint(moveDistance.X, 0.0f);
                            break;

                        default:
                            break;
                        }

                        newX = container.Position.X + moveDistance.X;
                        newY = container.Position.Y + moveDistance.Y;

                        scrollDistance = moveDistance;
                        SetContentOffset(new CCPoint(newX, newY));
                    }
                }
                else if (touches.Count == 2 && !Dragging)
                {
                    float len = CCPoint.Distance(Layer.ScreenToWorldspace(touches[0].LocationOnScreen),
                                                 Layer.ScreenToWorldspace(touches[1].LocationOnScreen));
                    ZoomScale = ZoomScale * len / touchLength;
                }
            }
        }
コード例 #58
0
 void OnTouchEnded(CCTouch touch, CCEvent touchEvent)
 {
     PotentiometerEnded(CCPoint.Zero);
 }
コード例 #59
0
        void OnTouchMoved(CCTouch pTouch, CCEvent touchEvent)
        {
            CCPoint location = LocationFromTouch(pTouch);

            SliderMoved(location);
        }