本文整理汇总了C#中cocos2d.CCRect.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# CCRect.Equals方法的具体用法?C# CCRect.Equals怎么用?C# CCRect.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocos2d.CCRect
的用法示例。
在下文中一共展示了CCRect.Equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateWithBatchNode
public bool UpdateWithBatchNode(CCSpriteBatchNode batchnode, CCRect rect, bool rotated, CCRect capInsets)
{
byte opacity = m_cOpacity;
CCColor3B color = m_tColor;
// Release old sprites
RemoveAllChildrenWithCleanup(true);
if (scale9Image != batchnode)
{
scale9Image = batchnode;
}
scale9Image.RemoveAllChildrenWithCleanup(true);
m_capInsets = capInsets;
// If there is no given rect
if (rect.Equals(CCRect.Zero))
{
// Get the texture size as original
CCSize textureSize = scale9Image.TextureAtlas.Texture.ContentSize;
rect = new CCRect(0, 0, textureSize.Width, textureSize.Height);
}
// Set the given rect's size as original size
m_spriteRect = rect;
m_originalSize = rect.Size;
m_preferredSize = m_originalSize;
m_capInsetsInternal = capInsets;
// Get the image edges
float l = rect.Origin.X;
float t = rect.Origin.Y;
float h = rect.Size.Height;
float w = rect.Size.Width;
// If there is no specified center region
if (m_capInsetsInternal.Equals(CCRect.Zero))
{
// Apply the 3x3 grid format
if (rotated)
{
m_capInsetsInternal = new CCRect(l + h / 3, t + w / 3, w / 3, h / 3);
}
else
{
m_capInsetsInternal = new CCRect(l + w / 3, t + h / 3, w / 3, h / 3);
}
}
//
// Set up the image
//
if (rotated)
{
// Sprite frame is rotated
// Centre
centre = new CCSprite();
centre.InitWithTexture(scale9Image.Texture, m_capInsetsInternal, true);
scale9Image.AddChild(centre, 0, (int) Positions.pCentre);
// Bottom
bottom = new CCSprite();
bottom.InitWithTexture(scale9Image.Texture, new CCRect(l,
m_capInsetsInternal.Origin.Y,
m_capInsetsInternal.Size.Width,
m_capInsetsInternal.Origin.X - l),
rotated
);
scale9Image.AddChild(bottom, 1, (int) Positions.pBottom);
// Top
top = new CCSprite();
top.InitWithTexture(scale9Image.Texture, new CCRect(m_capInsetsInternal.Origin.X + m_capInsetsInternal.Size.Height,
m_capInsetsInternal.Origin.Y,
m_capInsetsInternal.Size.Width,
h - m_capInsetsInternal.Size.Height - (m_capInsetsInternal.Origin.X - l)),
rotated
);
scale9Image.AddChild(top, 1, (int) Positions.pTop);
// Right
right = new CCSprite();
right.InitWithTexture(scale9Image.Texture, new CCRect(m_capInsetsInternal.Origin.X,
m_capInsetsInternal.Origin.Y + m_capInsetsInternal.Size.Width,
w - (m_capInsetsInternal.Origin.Y - t) - m_capInsetsInternal.Size.Width,
m_capInsetsInternal.Size.Height),
rotated
);
scale9Image.AddChild(right, 1, (int) Positions.pRight);
// Left
left = new CCSprite();
left.InitWithTexture(scale9Image.Texture, new CCRect(m_capInsetsInternal.Origin.X,
t,
m_capInsetsInternal.Origin.Y - t,
m_capInsetsInternal.Size.Height),
//.........这里部分代码省略.........
示例2: InitWithTarget
private bool InitWithTarget(CCNode pFollowedNode, CCRect rect)
{
Debug.Assert(pFollowedNode != null);
m_pobFollowedNode = pFollowedNode;
if (rect.Equals(CCRect.Zero))
{
m_bBoundarySet = false;
}
else
{
m_bBoundarySet = true;
}
m_bBoundaryFullyCovered = false;
CCSize winSize = CCDirector.SharedDirector.WinSize;
m_obFullScreenSize = new CCPoint(winSize.Width, winSize.Height);
m_obHalfScreenSize = CCPointExtension.Multiply(m_obFullScreenSize, 0.5f);
if (m_bBoundarySet)
{
m_fLeftBoundary = -((rect.Origin.X + rect.Size.Width) - m_obFullScreenSize.X);
m_fRightBoundary = -rect.Origin.X;
m_fTopBoundary = -rect.Origin.Y;
m_fBottomBoundary = -((rect.Origin.Y + rect.Size.Height) - m_obFullScreenSize.Y);
if (m_fRightBoundary < m_fLeftBoundary)
{
// screen width is larger than world's boundary width
//set both in the middle of the world
m_fRightBoundary = m_fLeftBoundary = (m_fLeftBoundary + m_fRightBoundary) / 2;
}
if (m_fTopBoundary < m_fBottomBoundary)
{
// screen width is larger than world's boundary width
//set both in the middle of the world
m_fTopBoundary = m_fBottomBoundary = (m_fTopBoundary + m_fBottomBoundary) / 2;
}
if ((m_fTopBoundary == m_fBottomBoundary) && (m_fLeftBoundary == m_fRightBoundary))
{
m_bBoundaryFullyCovered = true;
}
}
return true;
}