本文整理汇总了C#中CocosSharp.CCSprite.UpdateDisplayedOpacity方法的典型用法代码示例。如果您正苦于以下问题:C# CCSprite.UpdateDisplayedOpacity方法的具体用法?C# CCSprite.UpdateDisplayedOpacity怎么用?C# CCSprite.UpdateDisplayedOpacity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CocosSharp.CCSprite
的用法示例。
在下文中一共展示了CCSprite.UpdateDisplayedOpacity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSpriteWithFontDefinition
void CreateSpriteWithFontDefinition(CCFontDefinition fontDefinition)
{
if (textSprite != null)
textSprite.RemoveFromParent();
var texture = CreateTextSprite(Text, fontDefinition);
textSprite = new CCSprite(texture);
textSprite.IsAntialiased = isAntialiased;
textSprite.BlendFunc = BlendFunc;
textSprite.AnchorPoint = CCPoint.AnchorLowerLeft;
base.ContentSize = textSprite.ContentSize;
base.AddChild(textSprite,0,TagInvalid);
textSprite.UpdateDisplayedColor(DisplayedColor);
textSprite.UpdateDisplayedOpacity(DisplayedOpacity);
}
示例2: CreateFontChars
//.........这里部分代码省略.........
// unichar is a short, and an int is needed on HASH_FIND_INT
if (!FontConfiguration.Glyphs.TryGetValue(c, out fontDef))
{
CCLog.Log("CocosSharp: CCLabelBMFont: characer not found {0}", (int)c);
continue;
}
fontCharTextureRect = fontDef.Subrect;
fontCharTextureRect.Origin.X += ImageOffset.X;
fontCharTextureRect.Origin.Y += ImageOffset.Y;
fontCharContentSize = fontCharTextureRect.Size / DefaultTexelToContentSizeRatios;
CCSprite fontChar;
//bool hasSprite = true;
fontChar = (CCSprite)(this[i]);
if (fontChar != null)
{
// Reusing previous Sprite
fontChar.Visible = true;
// updating previous sprite
fontChar.IsTextureRectRotated = false;
fontChar.ContentSize = fontCharContentSize;
fontChar.TextureRectInPixels = fontCharTextureRect;
}
else
{
// New Sprite ? Set correct color, opacity, etc...
//if( false )
//{
// /* WIP: Doesn't support many features yet.
// But this code is super fast. It doesn't create any sprite.
// Ideal for big labels.
// */
// fontChar = m_pReusedChar;
// fontChar.BatchNode = null;
// hasSprite = false;
//}
//else
{
fontChar = new CCSprite(TextureAtlas.Texture, fontCharTextureRect);
fontChar.ContentSize = fontCharContentSize;
AddChild(fontChar, i, i);
}
// Apply label properties
fontChar.IsColorModifiedByOpacity = IsColorModifiedByOpacity;
// Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on
fontChar.UpdateDisplayedColor(DisplayedColor);
fontChar.UpdateDisplayedOpacity(DisplayedOpacity);
}
// See issue 1343. cast( signed short + unsigned integer ) == unsigned integer (sign is lost!)
int yOffset = FontConfiguration.CommonHeight - fontDef.YOffset;
var fontPos =
new CCPoint(
(float)nextFontPositionX + fontDef.XOffset + fontDef.Subrect.Size.Width * 0.5f + kerningAmount,
(float)nextFontPositionY + yOffset - fontCharTextureRect.Size.Height * 0.5f);
fontChar.Position = fontPos;
// update kerning
nextFontPositionX += fontDef.XAdvance + kerningAmount;
prev = c;
if (longestLine < nextFontPositionX)
{
longestLine = nextFontPositionX;
}
}
// If the last character processed has an xAdvance which is less that the width of the characters image, then we need
// to adjust the width of the string to take this into account, or the character will overlap the end of the bounding
// box
if (fontDef.XAdvance < fontDef.Subrect.Size.Width)
{
tmpSize.Width = longestLine + fontDef.Subrect.Size.Width - fontDef.XAdvance;
}
else
{
tmpSize.Width = longestLine;
}
tmpSize.Height = totalHeight;
var tmpDimensions = labelDimensions;
labelDimensions = new CCSize(
labelDimensions.Width > 0 ? labelDimensions.Width : tmpSize.Width,
labelDimensions.Height > 0 ? labelDimensions.Height : tmpSize.Height
);
ContentSize = labelDimensions;
labelDimensions = tmpDimensions;
}