本文整理汇总了C#中cocos2d.CCSize类的典型用法代码示例。如果您正苦于以下问题:C# CCSize类的具体用法?C# CCSize怎么用?C# CCSize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CCSize类属于cocos2d命名空间,在下文中一共展示了CCSize类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: updateSize
public void updateSize(CCPoint touchLocation)
{
CCSize s = CCDirector.SharedDirector.WinSize;
CCSize newSize = new CCSize(Math.Abs(touchLocation.X - s.Width / 2) * 2, Math.Abs(touchLocation.Y - s.Height / 2) * 2);
CCLayerColor l = (CCLayerColor)GetChildByTag(kTagLayer);
l.ContentSize = newSize;
}
示例2: CCSizeApplyAffineTransform
public static CCSize CCSizeApplyAffineTransform(CCSize size, CCAffineTransform t)
{
CCSize s = new CCSize();
s.width = (float)((double)t.a * size.width + (double)t.c * size.height);
s.height = (float)((double)t.b * size.width + (double)t.d * size.height);
return s;
}
示例3: Create
public static CCGrid3D Create(CCGridSize gridSize, CCSize size)
{
var pRet = new CCGrid3D();
if (pRet.InitWithSize(gridSize, size))
{
return pRet;
}
return null;
}
示例4: updateSize
public void updateSize(CCTouch touch)
{
CCPoint touchLocation = touch.locationInView(touch.view());
touchLocation = CCDirector.sharedDirector().convertToGL(touchLocation);
CCSize s = CCDirector.sharedDirector().getWinSize();
CCSize newSize = new CCSize(Math.Abs(touchLocation.x - s.width / 2) * 2, Math.Abs(touchLocation.y - s.height / 2) * 2);
CCLayerColor l = (CCLayerColor)getChildByTag(kTagLayer);
l.contentSize = newSize;
}
示例5: labelWithString
/// <summary>
/// creates a CCLabelTTF from a fontname, alignment, dimension and font size
/// </summary>
public static CCLabelTTF labelWithString(string label, CCSize dimensions, CCTextAlignment alignment, string fontName, float fontSize)
{
CCLabelTTF pRet = new CCLabelTTF();
if (pRet != null && pRet.initWithString(label, dimensions, alignment, fontName, fontSize))
{
return pRet;
}
return null;
}
示例6: BackGroundInit
/// <summary>
/// 背景初始化
/// </summary>
private void BackGroundInit(CCSize p_Size)
{
CCTexture2D backgroud = Media.PictureManager.GetCCTexture2DWithFile("image/BackGround");
CCSprite pSprite = CCSprite.spriteWithTexture(backgroud);
// position the sprite on the center of the screen
pSprite.position = new CCPoint(p_Size.width / 2, p_Size.height / 2);
// add the sprite as a child to this layer
this.addChild(pSprite, 0);
}
示例7: showFont
public void showFont(string pFont)
{
CCSize s = CCDirector.SharedDirector.WinSize;
var blockSize = new CCSize(s.Width / 3, 200);
float fontSize = 26;
RemoveChildByTag(kTagLabel1, true);
RemoveChildByTag(kTagLabel2, true);
RemoveChildByTag(kTagLabel3, true);
RemoveChildByTag(kTagLabel4, true);
CCLabelTTF top = new CCLabelTTF(pFont, pFont, 24);
CCLabelTTF left = new CCLabelTTF("alignment left", pFont, fontSize,
blockSize, CCTextAlignment.CCTextAlignmentLeft,
FontTestScene.verticalAlignment[FontTestScene.vAlignIdx]);
CCLabelTTF center = new CCLabelTTF("alignment center", pFont, fontSize,
blockSize, CCTextAlignment.CCTextAlignmentCenter,
FontTestScene.verticalAlignment[FontTestScene.vAlignIdx]);
CCLabelTTF right = new CCLabelTTF("alignment right", pFont, fontSize,
blockSize, CCTextAlignment.CCTextAlignmentRight,
FontTestScene.verticalAlignment[FontTestScene.vAlignIdx]);
CCLayerColor leftColor = new CCLayerColor(new CCColor4B(100, 100, 100, 255), blockSize.Width, blockSize.Height);
CCLayerColor centerColor = new CCLayerColor(new CCColor4B(200, 100, 100, 255), blockSize.Width, blockSize.Height);
CCLayerColor rightColor = new CCLayerColor(new CCColor4B(100, 100, 200, 255), blockSize.Width, blockSize.Height);
leftColor.IgnoreAnchorPointForPosition = false;
centerColor.IgnoreAnchorPointForPosition = false;
rightColor.IgnoreAnchorPointForPosition = false;
top.AnchorPoint = new CCPoint(0.5f, 1);
left.AnchorPoint = new CCPoint(0, 0.5f);
leftColor.AnchorPoint = new CCPoint(0, 0.5f);
center.AnchorPoint = new CCPoint(0, 0.5f);
centerColor.AnchorPoint = new CCPoint(0, 0.5f);
right.AnchorPoint = new CCPoint(0, 0.5f);
rightColor.AnchorPoint = new CCPoint(0, 0.5f);
top.Position = new CCPoint(s.Width / 2, s.Height - 20);
left.Position = new CCPoint(0, s.Height / 2);
leftColor.Position = left.Position;
center.Position = new CCPoint(blockSize.Width, s.Height / 2);
centerColor.Position = center.Position;
right.Position = new CCPoint(blockSize.Width * 2, s.Height / 2);
rightColor.Position = right.Position;
AddChild(leftColor, -1);
AddChild(left, 0, kTagLabel1);
AddChild(rightColor, -1);
AddChild(right, 0, kTagLabel2);
AddChild(centerColor, -1);
AddChild(center, 0, kTagLabel3);
AddChild(top, 0, kTagLabel4);
}
示例8: OnHandlePropTypeSize
protected override void OnHandlePropTypeSize(CCNode node, CCNode parent, string propertyName, CCSize pSize, CCBReader reader)
{
if (propertyName == PROPERTY_CONTENTSIZE)
{
((CCScrollView) node).ViewSize = pSize;
}
else
{
base.OnHandlePropTypeSize(node, parent, propertyName, pSize, reader);
}
}
示例9: initWithPlaceHolder
//////////////////////////////////////////////////////////////////////////
// initialize
//////////////////////////////////////////////////////////////////////////
/** initializes the CCTextFieldTTF with a font name, alignment, dimension and font size */
public bool initWithPlaceHolder(string placeholder, CCSize dimensions, CCTextAlignment alignment, string fontName, float fontSize)
{
if (placeholder != null)
{
//CC_SAFE_DELETE(m_pPlaceHolder);
m_pPlaceHolder = placeholder;
}
return cclabelttf.initWithString(m_pPlaceHolder, dimensions, alignment, fontName, fontSize);
//throw new NotFiniteNumberException();
}
示例10: InitWithTileFile
public bool InitWithTileFile(string tile, string mapFile, int tileWidth, int tileHeight)
{
LoadTgAfile(mapFile);
CalculateItemsToRender();
if (base.InitWithTileFile(tile, tileWidth, tileHeight, m_nItemsToRender))
{
m_tColor = CCTypes.CCWhite;
m_pPosToAtlasIndex = new Dictionary<CCGridSize, int>();
UpdateAtlasValues();
ContentSize = new CCSize(m_pTGAInfo.width * m_uItemWidth, m_pTGAInfo.height * m_uItemHeight);
return true;
}
return false;
}
示例11: initWithString
/// <summary>
/// initializes the CCLabelTTF with a font name, alignment, dimension and font size
/// </summary>
public bool initWithString(string label, CCSize dimensions, CCTextAlignment alignment, string fontName, float fontSize)
{
Debug.Assert(label != null);
if (init())
{
m_tDimensions = new CCSize(dimensions.width * CCDirector.sharedDirector().ContentScaleFactor, dimensions.height * CCDirector.sharedDirector().ContentScaleFactor);
m_eAlignment = alignment;
m_pFontName = fontName;
m_fFontSize = fontSize * CCDirector.sharedDirector().ContentScaleFactor;
this.setString(label);
return true;
}
return false;
}
示例12: textFieldWithPlaceHolder
//char * description();
//////////////////////////////////////////////////////////////////////////
// static constructor
//////////////////////////////////////////////////////////////////////////
/** creates a CCTextFieldTTF from a fontname, alignment, dimension and font size */
public static CCTextFieldTTF textFieldWithPlaceHolder(string placeholder, CCSize dimensions, CCTextAlignment alignment, string fontName, float fontSize)
{
CCTextFieldTTF pRet = new CCTextFieldTTF();
if (pRet != null && pRet.initWithPlaceHolder("", dimensions, alignment, fontName, fontSize))
{
//pRet->autorelease();
if (placeholder != null)
{
pRet.PlaceHolder = placeholder;
}
return pRet;
}
//CC_SAFE_DELETE(pRet);
return null;
throw new NotFiniteNumberException();
}
示例13: CCSizeFromString
public static CCSize CCSizeFromString(string pszContent)
{
CCSize ret = new CCSize();
do
{
List<string> strs = new List<string>();
if (!CCUtils.SplitWithForm(pszContent, strs)) break;
float width = CCUtils.CCParseFloat(strs[0]);
float height = CCUtils.CCParseFloat(strs[1]);
ret = new CCSize(width, height);
} while (false);
return ret;
}
示例14: MathSize
/// <summary>
/// 获取均分屏幕的尺寸 默认屏幕宽800 高480
/// </summary>
/// <param name="p_Width">800</param>
/// <param name="p_Height">480</param>
/// <param name="p_AverageNumber">均分</param>
/// <returns></returns>
public static CCSize MathSize(Int32 p_Width, Int32 p_Height, Int32 p_AverageNumber,Int32 p_While)
{
CCSize size = new CCSize();
size.width = p_Width / ((p_AverageNumber / 2)==1?2:(p_AverageNumber / 2));
if (p_AverageNumber / 2 > 1)
{
size.height = p_Height / 2;
}
else
{
size.height = p_Height;
}
size.width -= p_While*2;
size.height -= p_While * 2;
return size;
}
示例15: GetAbsolutePosition
public static CCPoint GetAbsolutePosition(CCPoint pt, kCCBPositionType nType, CCSize containerSize, string pPropName)
{
CCPoint absPt = new CCPoint(0, 0);
if (nType == kCCBPositionType.kCCBPositionTypeRelativeBottomLeft)
{
absPt = pt;
}
else if (nType == kCCBPositionType.kCCBPositionTypeRelativeTopLeft)
{
absPt.X = pt.X;
absPt.Y = containerSize.Height - pt.Y;
}
else if (nType == kCCBPositionType.kCCBPositionTypeRelativeTopRight)
{
absPt.X = containerSize.Width - pt.X;
absPt.Y = containerSize.Height - pt.Y;
}
else if (nType == kCCBPositionType.kCCBPositionTypeRelativeBottomRight)
{
absPt.X = containerSize.Width - pt.X;
absPt.Y = pt.Y;
}
else if (nType == kCCBPositionType.kCCBPositionTypePercent)
{
absPt.X = (int) (containerSize.Width * pt.X / 100.0f);
absPt.Y = (int) (containerSize.Height * pt.Y / 100.0f);
}
else if (nType == kCCBPositionType.kCCBPositionTypeMultiplyResolution)
{
float resolutionScale = CCBReader.ResolutionScale;
absPt.X = pt.X * resolutionScale;
absPt.Y = pt.Y * resolutionScale;
}
return absPt;
}