本文整理汇总了C#中cocos2d.CCSize.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# CCSize.Equals方法的具体用法?C# CCSize.Equals怎么用?C# CCSize.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocos2d.CCSize
的用法示例。
在下文中一共展示了CCSize.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitWithString
public bool InitWithString(string text, CCSize dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, string fontName,
float fontSize)
{
try
{
m_CallParams = new object[] { text, dimensions, hAlignment, vAlignment, fontName, fontSize };
// CCLog.Log("InitWithString: text={0}", text);
Debug.Assert(dimensions.Width >= 0 || dimensions.Height >= 0);
if (string.IsNullOrEmpty(text))
{
return false;
}
SpriteFont font = m_spriteFont;
if (font == null)
{
font = CCSpriteFontCache.SharedInstance.GetFont(fontName, fontSize);
if (font == null)
{
CCLog.Log("Can't find {0}, use system default ({1})", fontName, DrawManager.DefaultFont);
font = CCSpriteFontCache.SharedInstance.GetFont(DrawManager.DefaultFont, fontSize);
if (font == null)
{
CCLog.Log("Failed to load default font. No font supported.");
}
}
// m_spriteFont = font;
}
if (font == null)
return (false);
// m_spriteFont = font;
if (dimensions.Equals(CCSize.Zero))
{
Microsoft.Xna.Framework.Vector2 temp = font.MeasureString(text);
dimensions.Width = temp.X;
dimensions.Height = temp.Y;
}
//float scale = 1.0f;//need refer fontSize;
var textList = new List<String>();
var nextText = new StringBuilder();
string[] lineList = text.Split('\n');
float spaceWidth = font.MeasureString(" ").X;
for (int j = 0; j < lineList.Length; ++j)
{
string[] wordList = lineList[j].Split(' ');
float lineWidth = 0;
bool firstWord = true;
for (int i = 0; i < wordList.Length; ++i)
{
lineWidth += font.MeasureString(wordList[i]).X;
if (lineWidth > dimensions.Width)
{
lineWidth = 0;
if (nextText.Length > 0)
{
firstWord = true;
textList.Add(nextText.ToString());
#if XBOX || XBOX360
nextText.Length = 0;
#else
nextText.Clear();
#endif
}
else
{
firstWord = false;
textList.Add(wordList[i]);
continue;
}
}
if (!firstWord)
{
nextText.Append(' ');
lineWidth += spaceWidth;
}
nextText.Append(wordList[i]);
firstWord = false;
}
textList.Add(nextText.ToString());
#if XBOX || XBOX360
nextText.Length = 0;
#else
nextText.Clear();
//.........这里部分代码省略.........