本文整理汇总了C#中cocos2d.CCSprite.initWithBatchNodeRectInPixels方法的典型用法代码示例。如果您正苦于以下问题:C# CCSprite.initWithBatchNodeRectInPixels方法的具体用法?C# CCSprite.initWithBatchNodeRectInPixels怎么用?C# CCSprite.initWithBatchNodeRectInPixels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocos2d.CCSprite
的用法示例。
在下文中一共展示了CCSprite.initWithBatchNodeRectInPixels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createFontChars
/// <summary>
/// updates the font chars based on the string to render
/// </summary>
public void createFontChars()
{
int nextFontPositionX = 0;
int nextFontPositionY = 0;
int prev = -1;
int kerningAmount = 0;
CCSize tmpSize = new CCSize(0, 0);
int longestLine = 0;
int totalHeight = 0;
int quantityOfLines = 1;
int stringLen = m_sString.Length;
if (0 == stringLen)
{
return;
}
for (int i = 0; i < stringLen - 1; ++i)
{
ushort c = m_sString[i];
if (c == '\n')
{
quantityOfLines++;
}
}
totalHeight = m_pConfiguration.m_uCommonHeight * quantityOfLines;
nextFontPositionY = -(m_pConfiguration.m_uCommonHeight - m_pConfiguration.m_uCommonHeight * quantityOfLines);
for (int i = 0; i < stringLen; i++)
{
int c = m_sString[i];
if (c >= kCCBMFontMaxChars)
{
throw (new ArgumentException("LabelBMFont: character " + m_sString[i] + " outside of max font characters, which is " + kCCBMFontMaxChars));
}
if (c == '\n')
{
nextFontPositionX = 0;
nextFontPositionY -= (int)m_pConfiguration.m_uCommonHeight;
continue;
}
kerningAmount = this.kerningAmountForFirst(prev, c);
if (!m_pConfiguration.m_pBitmapFontArray.ContainsKey(c))
{
throw(new ArgumentException("Character " + c + " in LabelBMFont is not in the font definition."));
}
ccBMFontDef fontDef = m_pConfiguration.m_pBitmapFontArray[c];
CCRect rect = fontDef.rect;
CCSprite fontChar = (CCSprite)(this.getChildByTag(i));
if (fontChar == null)
{
fontChar = new CCSprite();
fontChar.initWithBatchNodeRectInPixels(this, rect);
this.addChild(fontChar, 0, i);
}
else
{
// reusing fonts
//fontChar = new CCSprite();
fontChar.setTextureRectInPixels(rect, false, rect.size);
// restore to default in case they were modified
fontChar.visible = true;
fontChar.Opacity = 255;
}
float yOffset = (float)(m_pConfiguration.m_uCommonHeight - fontDef.yOffset);
fontChar.positionInPixels = (new CCPoint(nextFontPositionX + fontDef.xOffset + fontDef.rect.size.width / 2.0f + kerningAmount,
(float)nextFontPositionY + yOffset - rect.size.height / 2.0f));
// NSLog(@"position.y: %f", fontChar.position.y);
// update kerning
nextFontPositionX += m_pConfiguration.m_pBitmapFontArray[c].xAdvance + kerningAmount;
prev = c;
// Apply label properties
fontChar.IsOpacityModifyRGB = m_bIsOpacityModifyRGB;
// Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on
fontChar.Color = m_tColor;
// only apply opaccity if it is different than 255 )
// to prevent modifying the color too (issue #610)
if (m_cOpacity != 255)
{
fontChar.Opacity = m_cOpacity;
}
//.........这里部分代码省略.........