当前位置: 首页>>代码示例>>C#>>正文


C# CCRect.ContainsPoint方法代码示例

本文整理汇总了C#中CCRect.ContainsPoint方法的典型用法代码示例。如果您正苦于以下问题:C# CCRect.ContainsPoint方法的具体用法?C# CCRect.ContainsPoint怎么用?C# CCRect.ContainsPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCRect的用法示例。


在下文中一共展示了CCRect.ContainsPoint方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: OnEnter

		public override void OnEnter ()
		{

			spriteSaved = false;

			base.OnEnter ();

			var origin = Layer.VisibleBoundsWorldspace.Origin;
			var size = Layer.VisibleBoundsWorldspace.Size;

			//MenuItemFont::setFontSize(20);

			var sprite = new CCSprite("Images/CyanSquare.png");
			sprite.Position = origin + size.Center;
			AddChild(sprite, 10);

			// Make sprite1 touchable
			var listener1 = new CCEventListenerTouchOneByOne ();
			listener1.IsSwallowTouches = true;

			listener1.OnTouchBegan = (touch, touchEvent) => 
			{
				var target = (CCSprite) touchEvent.CurrentTarget;

				var locationInNode = target.Layer.ScreenToWorldspace(touch.LocationOnScreen);
				var s = target.ContentSize;
				var rect = new CCRect(0, 0, s.Width, s.Height);

				if (rect.ContainsPoint(locationInNode))
				{
					CCLog.Log("sprite began... x = {0}, y = {1}", locationInNode.X, locationInNode.Y);
					target.Opacity = 180;
					return true;
				}
				return false;
			};

			listener1.OnTouchMoved = (touch, touchEvent) =>
			{
				var target = (CCSprite) touchEvent.CurrentTarget;
				target.Position += touch.Delta;
			};

			listener1.OnTouchEnded = (touch, touchEvent) =>
			{
				var target = (CCSprite) touchEvent.CurrentTarget;
				CCLog.Log("sprite onTouchesEnded.. ");
				target.Opacity = 255;
			};

            sprite.AddEventListener(listener1);

			RunActions(new CCDelayTime(5.0f),
				new CCCallFunc(() => 
				{
					spriteSaved = true;
					sprite.RemoveFromParent();
				}),
				new CCDelayTime(5.0f),
				new CCCallFunc(() =>
				{
					spriteSaved = false;
					AddChild(sprite);
				})
			);


		}
开发者ID:netonjm,项目名称:CocosSharp,代码行数:68,代码来源:EventDispatcherTestDemo.cs

示例3: IsPointInNode

		bool IsPointInNode(CCPoint pt, CCNode node)
		{
			var locationInNode = node.Layer.ScreenToWorldspace(pt);
			var s = node.ContentSize;
			var rect = new CCRect(0, 0, s.Width, s.Height);

			if (rect.ContainsPoint(locationInNode))
			{
				return true;
			}
			return false;
		}
开发者ID:netonjm,项目名称:CocosSharp,代码行数:12,代码来源:EventDispatcherTestDemo.cs

示例4: ToucheBegan

        private bool ToucheBegan(CCTouch touch, CCEvent e)
        {
            var colorToMove = this.piece.Board.IsWhiteMove ? PieceColor.White : PieceColor.Black;
            if (colorToMove != this.piece.Color)
            {
                return false;
            }

            this.initPosition = this.Position;
            var scaledWidth = ContentSize.Width * ScaleX;
            var scaledHeight = ContentSize.Height * ScaleY;

            var rect = new CCRect(
                PositionWorldspace.X - scaledWidth / 2,
                PositionWorldspace.Y - scaledHeight / 2,
                scaledWidth,
                scaledHeight);

            if (!rect.ContainsPoint(touch.Location))
            {
                return false;
            }

            this.AnchorPoint = new CCPoint(0.2f, 0.5f);
            this.Scale = this.ScaleX * 3f;
            this.possibleSquares = this.piece.PossibleMoves().ToList();
            this.DrawPossibleMoves();
            return true;
        }
开发者ID:AGRocks,项目名称:chezzles,代码行数:29,代码来源:CocoPiece.cs

示例5: OnTouchBegan

        private bool OnTouchBegan(CCTouch touch, CCEvent e)
        {
            if (!Visible)
            {
                return false;
            }

            var rect = new CCRect(PositionWorldspace.X, PositionWorldspace.Y, ContentSize.Width, ContentSize.Height);
            if (!rect.ContainsPoint(touch.Location))
            {
                return false;
            }

            OnKeyDown();
            return true;
        }
开发者ID:ToraiRei,项目名称:cozy,代码行数:16,代码来源:BaseButton.cs

示例6: OnTouchEnded

        public void OnTouchEnded(CCTouch touch, CCEvent e)
        {
            if (!Visible)
            {
                return;
            }

            var beginrect = new CCRect(StartPoint.X, StartPoint.Y, ContentSize.Width, ContentSize.Height);
            if(!beginrect.ContainsPoint(touch.Location))
            {
                return;
            }

            var rect = new CCRect(PositionWorldspace.X, PositionWorldspace.Y, ContentSize.Width, ContentSize.Height);
            if (!rect.ContainsPoint(touch.Location))
            {
                return;
            }
            OnKeyUp();
        }
开发者ID:xxy1991,项目名称:cozy,代码行数:20,代码来源:BaseButton.cs

示例7: RouteTouchUp

 public static void RouteTouchUp(CCNode root, Touch touch)
 {
     CCPoint touchLocation = touch.CCTouch.Location;
     if (root.ChildrenCount > 0)
     {
         for (int i = root.ChildrenCount - 1; i >= 0; i--)
         {
             RouteTouchUp(root.Children[i], touch);  //递归
             if (touch.Handled == true) return;
             ITouch itouch = root.Children[i] as ITouch;
             if (itouch != null)
             {
                 CCNode node = root.Children[i] as CCNode;
                 if (node.Parent.Visible == true && node.Visible == true)
                 {
                     CCPoint local = node.ConvertToNodeSpace(touchLocation);
                     CCRect r = new CCRect(
                         node.PositionX - node.ContentSize.Width * node.AnchorPoint.X,
                         node.PositionY - node.ContentSize.Height * node.AnchorPoint.Y,
                         node.ContentSize.Width,
                         node.ContentSize.Height
                         );
                     r.Origin = CCPoint.Zero;
                     if (r.ContainsPoint(local))
                         itouch.OnTouchDown(touch);
                 }
             }
         }
     }
 }
开发者ID:liwq-net,项目名称:UIFactory,代码行数:30,代码来源:XAML.cs


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