本文整理汇总了C#中CCRect.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# CCRect.Equals方法的具体用法?C# CCRect.Equals怎么用?C# CCRect.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCRect
的用法示例。
在下文中一共展示了CCRect.Equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CCFollow
public CCFollow(CCNode followedNode, CCRect rect)
{
Debug.Assert (followedNode != null);
FollowedNode = followedNode;
if (rect.Equals (CCRect.Zero))
{
UsingBoundary = false;
}
else
{
UsingBoundary = true;
}
BoundaryFullyCovered = false;
CCRect viewportBounds = followedNode.Layer.VisibleBoundsWorldspace;
FullScreenSize = (CCPoint)new CCPoint(viewportBounds.Size.Width, viewportBounds.Size.Height);
HalfScreenSize = FullScreenSize * 0.5f;
if (UsingBoundary)
{
float leftBoundary = -((rect.Origin.X + rect.Size.Width) - FullScreenSize.X - viewportBounds.Origin.X);
float rightBoundary = -rect.Origin.X;
float topBoundary = -rect.Origin.Y;
float bottomBoundary = -((rect.Origin.Y + rect.Size.Height) - FullScreenSize.Y - viewportBounds.Origin.Y);
if (rightBoundary < leftBoundary)
{
// screen width is larger than world's boundary width
//set both in the middle of the world
rightBoundary = leftBoundary = (leftBoundary + rightBoundary) / 2;
}
if (topBoundary < bottomBoundary)
{
// screen width is larger than world's boundary width
//set both in the middle of the world
topBoundary = bottomBoundary = (topBoundary + bottomBoundary) / 2;
}
if ((topBoundary == bottomBoundary) && (leftBoundary == rightBoundary))
{
BoundaryFullyCovered = true;
}
Boundary = new CCFollowBoundary (bottomBoundary, leftBoundary, rightBoundary, topBoundary);
}
}
示例2: UpdateWithBatchNode
public bool UpdateWithBatchNode(CCSpriteBatchNode batchnode, CCRect rect, bool rotated, CCRect capInsets)
{
var opacity = Opacity;
var color = Color;
// Release old sprites
RemoveAllChildren(true);
scale9Image = batchnode;
scale9Image.RemoveAllChildren(true);
this.capInsets = capInsets;
spriteFrameRotated = rotated;
// If there is no given rect
if (rect.Equals(CCRect.Zero))
{
// Get the texture size as original
CCSize textureSize = scale9Image.TextureAtlas.Texture.ContentSizeInPixels;
rect = new CCRect(0, 0, textureSize.Width, textureSize.Height);
}
// Set the given rect's size as original size
spriteRect = rect;
originalSize = rect.Size;
preferredSize = originalSize;
capInsetsInternal = capInsets;
float h = rect.Size.Height;
float w = rect.Size.Width;
// If there is no specified center region
if (capInsetsInternal.Equals(CCRect.Zero))
{
capInsetsInternal = new CCRect(w / 3, h / 3, w / 3, h / 3);
}
float left_w = capInsetsInternal.Origin.X;
float center_w = capInsetsInternal.Size.Width;
float right_w = rect.Size.Width - (left_w + center_w);
float top_h = capInsetsInternal.Origin.Y;
float center_h = capInsetsInternal.Size.Height;
float bottom_h = rect.Size.Height - (top_h + center_h);
// calculate rects
// ... top row
float x = 0.0f;
float y = 0.0f;
// top left
CCRect lefttopbounds = new CCRect(x, y, left_w, top_h);
// top center
x += left_w;
CCRect centertopbounds = new CCRect(x, y, center_w, top_h);
// top right
x += center_w;
CCRect righttopbounds = new CCRect(x, y, right_w, top_h);
// ... center row
x = 0.0f;
y = 0.0f;
y += top_h;
// center left
CCRect leftcenterbounds = new CCRect(x, y, left_w, center_h);
// center center
x += left_w;
CCRect centerbounds = new CCRect(x, y, center_w, center_h);
// center right
x += center_w;
CCRect rightcenterbounds = new CCRect(x, y, right_w, center_h);
// ... bottom row
x = 0.0f;
y = 0.0f;
y += top_h;
y += center_h;
// bottom left
CCRect leftbottombounds = new CCRect(x, y, left_w, bottom_h);
// bottom center
x += left_w;
CCRect centerbottombounds = new CCRect(x, y, center_w, bottom_h);
// bottom right
x += center_w;
CCRect rightbottombounds = new CCRect(x, y, right_w, bottom_h);
if (!rotated)
{
CCAffineTransform t = CCAffineTransform.Identity;
t = CCAffineTransform.Translate(t, rect.Origin.X, rect.Origin.Y);
//.........这里部分代码省略.........