本文整理汇总了C#中cocos2d.CCRect类的典型用法代码示例。如果您正苦于以下问题:C# CCRect类的具体用法?C# CCRect怎么用?C# CCRect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CCRect类属于cocos2d命名空间,在下文中一共展示了CCRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Selection
public Selection(Word p_StudyInfo, bool p_IsAnswer,Int32 p_Width,Int32 p_Height)
{
base.init();
this.StudyInfo = p_StudyInfo;
CCTexture2D texture = new CCTexture2D();
texture.initWithTexture(PictureManager.GetTexture2D(p_StudyInfo));
if (p_Width < texture.ContentSizeInPixels.width)
{
this.scaleX = p_Width / texture.ContentSizeInPixels.width;
}
if (p_Height < texture.ContentSizeInPixels.height)
{
this.scaleY = p_Height / texture.ContentSizeInPixels.height;
}
this.contentSize.width = p_Width;
this.contentSize.height = p_Height;
CCRect rect = new CCRect();
rect.size = new CCSize(texture.ContentSizeInPixels.width, texture.ContentSizeInPixels.height);
this.initWithTexture(texture, rect);
this.IsAnswer = p_IsAnswer;
LoadResultPeople();
}
示例2: CCSprite
public CCSprite(string fileName, CCRect rect)
{
if (!InitWithFile(fileName, rect))
{
CCLog.Log("CCSprite (string fileName, CCRect rect): Problems initializing class");
}
}
示例3: getRect
public static CCRect getRect(CCNode node)
{
CCRect rc = new CCRect();
rc.Origin = node.Position;
rc.Size = node.ContentSize;
rc.Origin.X -= rc.Size.Width / 2;
rc.Origin.Y -= rc.Size.Height / 2;
return rc;
}
示例4: getRect
public static CCRect getRect(CCNode pNode)
{
CCRect rc = new CCRect();
rc.origin = pNode.position;
rc.size = pNode.contentSize;
rc.origin.x -= rc.size.width / 2;
rc.origin.y -= rc.size.height / 2;
return rc;
}
示例5: addFrameWithFileName
/** Adds a frame with an image filename. Internally it will create a CCSpriteFrame and it will add it.
Added to facilitate the migration from v0.8 to v0.9.
*/
public void addFrameWithFileName(string pszFileName)
{
CCTexture2D pTexture = CCTextureCache.sharedTextureCache().addImage(pszFileName);
//CCRect rect = CCRectZero;
CCRect rect = new CCRect(0, 0, 0, 0);
rect.size = pTexture.getContentSize();
CCSpriteFrame pFrame = CCSpriteFrame.frameWithTexture(pTexture, rect);
//// m_pobFrames.addObject(pFrame);
m_pobFrames.Add(pFrame);
}
示例6: rectForGID
public CCRect rectForGID(int gid)
{
CCRect rect = new CCRect();
rect.size = m_tTileSize;
gid = gid - m_uFirstGid;
int max_x = (int)((m_tImageSize.width - m_uMargin * 2 + m_uSpacing) / (m_tTileSize.width + m_uSpacing));
// int max_y = (imageSize.height - margin*2 + spacing) / (tileSize.height + spacing);
rect.origin.x = (gid % max_x) * (m_tTileSize.width + m_uSpacing) + m_uMargin;
rect.origin.y = (gid / max_x) * (m_tTileSize.height + m_uSpacing) + m_uMargin;
return rect;
}
示例7: CCRectUnion
public static CCRect CCRectUnion(CCRect src1, CCRect src2)
{
CCRect result;
float x1 = Math.Min(src1.MinX, src2.MinX);
float y1 = Math.Min(src1.MinY, src2.MinY);
float x2 = Math.Max(src1.MaxX, src2.MaxX);
float y2 = Math.Max(src1.MaxY, src2.MaxY);
result.Origin = new CCPoint(x1,x2);
result.Size = new CCSize(x2-x1, y2-y1);
return result;
}
示例8: CCRectApplyAffineTransform
public static CCRect CCRectApplyAffineTransform(CCRect rect, CCAffineTransform anAffineTransform)
{
float top = CCRect.CCRectGetMinY(rect);
float left = CCRect.CCRectGetMinX(rect);
float right = CCRect.CCRectGetMaxX(rect);
float bottom = CCRect.CCRectGetMaxY(rect);
CCPoint topLeft = CCPointApplyAffineTransform(new CCPoint(left, top), anAffineTransform);
CCPoint topRight = CCPointApplyAffineTransform(new CCPoint(right, top), anAffineTransform);
CCPoint bottomLeft = CCPointApplyAffineTransform(new CCPoint(left, bottom), anAffineTransform);
CCPoint bottomRight = CCPointApplyAffineTransform(new CCPoint(right, bottom), anAffineTransform);
float minX = Math.Min(Math.Min(topLeft.x, topRight.x), Math.Min(bottomLeft.x, bottomRight.x));
float maxX = Math.Max(Math.Max(topLeft.x, topRight.x), Math.Max(bottomLeft.x, bottomRight.x));
float minY = Math.Min(Math.Min(topLeft.y, topRight.y), Math.Min(bottomLeft.y, bottomRight.y));
float maxY = Math.Max(Math.Max(topLeft.y, topRight.y), Math.Max(bottomLeft.y, bottomRight.y));
return new CCRect(minX, minY, (maxX - minX), (maxY - minY));
}
示例9: initWithTarget
public bool initWithTarget(CCNode followedNode, CCRect rect)
{
Debug.Assert(followedNode != null);
m_pobFollowedNode = followedNode;
m_bBoundarySet = true;
m_bBoundaryFullyCovered = false;
CCSize winSize = CCDirector.sharedDirector().getWinSize();
m_obFullScreenSize = new CCPoint(winSize.width, winSize.height);
m_obHalfScreenSize = CCPointExtension.ccpMult(m_obFullScreenSize, 0.5f);
m_fLeftBoundary = -((rect.origin.x + rect.size.width) - m_obFullScreenSize.x);
m_fRightBoundary = -rect.origin.x;
m_fLeftBoundary = -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;
}
示例10: CCScale9Sprite
public CCScale9Sprite(CCRect capInsets)
{
InitWithBatchNode(scale9Image, m_spriteRect, capInsets);
}
示例11: InitWithBatchNode
public bool InitWithBatchNode(CCSpriteBatchNode batchnode, CCRect rect, bool rotated, CCRect capInsets)
{
if (batchnode != null)
{
UpdateWithBatchNode(batchnode, rect, rotated, capInsets);
AnchorPoint = new CCPoint(0.5f, 0.5f);
}
m_positionsAreDirty = true;
return true;
}
示例12: 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),
//.........这里部分代码省略.........
示例13: ResizableSpriteWithCapInsets
public CCScale9Sprite ResizableSpriteWithCapInsets(CCRect capInsets)
{
var pReturn = new CCScale9Sprite();
pReturn.InitWithBatchNode(scale9Image, m_spriteRect, capInsets);
return pReturn;
}
示例14: initWithTexture
/// <summary>
/// Initializes an sprite with a texture.
/// The rect used will be the size of the texture.
/// The offset will be (0,0).
/// </summary>
public bool initWithTexture(CCTexture2D texture)
{
Debug.Assert(texture != null);
CCRect rect = new CCRect();
rect.size = texture.getContentSize();
return initWithTexture(texture, rect);
}
示例15: InitWithFile
public bool InitWithFile(CCRect capInsets, string file)
{
bool pReturn = InitWithFile(file, CCRect.Zero, capInsets);
return pReturn;
}