本文整理汇总了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;
}
}
}
}
示例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);
})
);
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
}
}
}
}