• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CocosSharp.CCTouch类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CocosSharp.CCTouch的典型用法代码示例。如果您正苦于以下问题:C# CCTouch类的具体用法?C# CCTouch怎么用?C# CCTouch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CCTouch类属于CocosSharp命名空间,在下文中一共展示了CCTouch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: onTouchMoved

		void onTouchMoved(CCTouch touch, CCEvent touchEvent)
        {
            CCPoint touchLocation = touch.LocationOnScreen;
            CCPoint nodePosition = Layer.ScreenToWorldspace(touchLocation);

            m_test.MouseMove(new b2Vec2(nodePosition.X, nodePosition.Y));
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:7,代码来源:Box2DView.cs


示例2: OnTouchEnded

 void OnTouchEnded(CCTouch  touch, CCEvent  touchEvent)
 {
     bool hits = touchHits(touch);
     if (hits && Triggered != null)
         Triggered(this, EventArgs.Empty);
     scaleButtonTo(1);
 }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:7,代码来源:CocosDenshionTest.cs


示例3: onTouchBegan

		bool onTouchBegan(CCTouch touch, CCEvent touchEvent)
        {
            if (m_state != PaddleState.kPaddleStateUngrabbed) return false;
            if (!containsTouchLocation(touch)) return false;

            m_state = PaddleState.kPaddleStateGrabbed;
            return true;
        }
开发者ID:netonjm,项目名称:CocosSharp,代码行数:8,代码来源:Paddle.cs


示例4: OnTouchBegan

            bool OnTouchBegan(CCTouch touch, CCEvent touchEvent)
            {
                bool hits = touchHits(touch);
                if (hits)
                    scaleButtonTo(0.9f);

                return hits;
            }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:8,代码来源:GameLayer.cs


示例5: OnTouchesEnded

 public void OnTouchesEnded(List<CCTouch> touches, CCEvent touchEvent)
 {
     foreach (CCTouch touch in touches) {
         if (touch == Touch) {
             Touch = null;
             return;
         }
     }
 }
开发者ID:AndyDentFree,项目名称:xfcs-play,代码行数:9,代码来源:DragSprite.cs


示例6: onTouchBegan

		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));

        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:10,代码来源:Box2DView.cs


示例7: onTouchBegan

		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;
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:11,代码来源:Box2DView.cs


示例8: OnTouchesBegan

 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;
             }
         }
     }
 }
开发者ID:AndyDentFree,项目名称:xfcs-play,代码行数:12,代码来源:DragSprite.cs


示例9: OnTouchEnded

 public void OnTouchEnded(CCTouch touch, CCEvent e)
 {
     if (Enable)
     {
         foreach (var control in ControlList)
         {
             var p = control.PositionWorldspace;
             var rect = new CCRect(p.X, p.Y, control.ContentSize.Width, control.ContentSize.Height);
             if (rect.ContainsPoint(Target.Layer.ScreenToWorldspace(touch.LocationOnScreen)))
             {
                 control.OnTouchEnded(touch, e);
                 return;
             }
         }
     }
 }
开发者ID:xxy1991,项目名称:cozy,代码行数:16,代码来源:ButtonEventDispatcher.cs


示例10: TouchMoved

		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;
                }
            }
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:76,代码来源:CCScrollView.cs


示例11: TouchBegan

        /** 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;
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:40,代码来源:CCScrollView.cs


示例12: OnTouchMoved

		void OnTouchMoved(CCTouch pTouch, CCEvent touchEvent)
        {
            CCPoint location = LocationFromTouch(pTouch);
            SliderMoved(location);
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:5,代码来源:CCControlSlider.cs


示例13: IsTouchInside

		public override bool IsTouchInside(CCTouch touch)
		{
			CCPoint touchLocation = touch.Location;

            CCRect rect = BoundingBoxTransformedToWorld;
			rect.Size.Width += ThumbSprite.ContentSize.Width;
			rect.Origin.X -= ThumbSprite.ContentSize.Width / 2;

			return rect.ContainsPoint(touchLocation);
		}
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:10,代码来源:CCControlSlider.cs


示例14: OnTouchMoved

        void OnTouchMoved(CCTouch touch, CCEvent touchEvent)
        {

            var touchLocation = touch.Location;
            float nMoveY = touchLocation.Y - beginTouchPos.Y;

            curPos = testListMenu.Position;
            CCPoint nextPos = new CCPoint(curPos.X, curPos.Y + nMoveY);
            CCRect visibleBounds = Layer.VisibleBoundsWorldspace;
            if (nextPos.Y < 0.0f)
            {
                testListMenu.Position = new CCPoint(0, 0);
                return;
            }

            if (nextPos.Y > (((int)TestCases.TESTS_COUNT + 1) * LINE_SPACE - visibleBounds.Size.Height))
            {
                testListMenu.Position = (new CCPoint(0, (((int)TestCases.TESTS_COUNT + 1) * LINE_SPACE - visibleBounds.Size.Height)));
                return;
            }

            testListMenu.Position = nextPos;
            beginTouchPos = touchLocation;
            curPos = nextPos;
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:25,代码来源:controller.cs


示例15: OnTouchBegan

 private bool OnTouchBegan(CCTouch arg1, CCEvent arg2)
 {
     return (true);
 }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:4,代码来源:GameLayer.cs


示例16: OnTouchEnded

        //public override void TouchEnded(CCTouch touch)
        //{

        //}

        private void OnTouchEnded(CCTouch arg1, CCEvent arg2)
        {
            float accel_filter = 0.1f;
            float ax = ConvertTouchToNodeSpace(arg1).X - ConvertToNodeSpace(arg1.PreviousLocationInView).X;
            ax /= 500;
            bird_vel.X = bird_vel.X * accel_filter + (float)ax * (1.0f - accel_filter) * 500.0f;
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:12,代码来源:GameLayer.cs


示例17: TouchEnded

		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;
            }
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:22,代码来源:CCScrollView.cs


示例18: TouchCancelled

		public virtual void TouchCancelled(CCTouch touch, CCEvent touchEvent)
        {
            if (!Visible)
            {
                return;
            }
            touches.Remove(touch);
            if (touches.Count == 0)
            {
                Dragging = false;
                IsTouchMoved = false;
            }
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:13,代码来源:CCScrollView.cs


示例19: OnTouchCancelled

		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;
            }
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:15,代码来源:CCControlSwitch.cs


示例20: OnTouchMoved

        private void OnTouchMoved(CCTouch arg1, CCEvent arg2)
        {

        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:4,代码来源:GameLayer.cs



注:本文中的CocosSharp.CCTouch类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CocosSharp.CCWindow类代码示例发布时间:2022-05-24
下一篇:
C# CocosSharp.CCSprite类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap