コード例 #1
0
 public bool InitWithString(string text, string fontName, float fontSize, CCSize dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment)
 {
     InitializeFont(fontName, fontSize, text);
     m_FontName = fontName;
     m_FontSize = fontSize;
     return(base.InitWithString(text, GetFontKey(fontName, fontSize), dimensions.PointsToPixels(), hAlignment, vAlignment, CCPoint.Zero, m_pTexture));
 }
コード例 #2
0
ファイル: CCLabelTTF.cs プロジェクト: krashman/cocos2d-xna
        private void updateTexture()
        {
            CCTexture2D tex;

            // Dump the old one
            if (Texture != null)
            {
                CCTexture2D tmp = Texture;
                Texture = null;
                tmp.Dispose();
            }

            // let system compute label's width or height when its value is 0
            // refer to cocos2d-x issue #1430
            tex = new CCTexture2D();

            var result = tex.InitWithString(m_pString,
                                            m_tDimensions.PointsToPixels(),
                                            m_hAlignment,
                                            m_vAlignment,
                                            m_pFontName,
                                            m_fFontSize * CCMacros.CCContentScaleFactor());

//#if MACOS || IPHONE || IOS
//			// There was a problem loading the text for some reason or another if result is not true
//			// For MonoMac and IOS Applications we will try to create a Native Label automatically
//			// If the font is not found then a default font will be selected by the device and used.
//			if (!result && !string.IsNullOrEmpty(m_pString))
//			{
//				tex = CCLabelUtilities.CreateLabelTexture (m_pString,
//				                                           CCMacros.CCSizePointsToPixels (m_tDimensions),
//				                                           m_hAlignment,
//				                                           m_vAlignment,
//				                                           m_pFontName,
//				                                           m_fFontSize * CCMacros.CCContentScaleFactor (),
//				                                           new CCColor4B(Microsoft.Xna.Framework.Color.White) );
//			}
//#endif
            if (result)
            {
                Texture = tex;

                CCRect rect = CCRect.Zero;
                rect.Size = m_pobTexture.ContentSize;
                SetTextureRect(rect);
            }
        }
コード例 #3
0
ファイル: CCLabel.cs プロジェクト: Ratel13/cocos2d-xna
        public bool InitWithString(string text, string fontName, float fontSize, CCSize dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment)
        {
            InitializeFont(fontName, fontSize, text);
			m_FontName = fontName;
			m_FontSize = fontSize;
            return base.InitWithString(text, GetFontKey(fontName, fontSize), dimensions.PointsToPixels(), hAlignment, vAlignment, CCPoint.Zero, m_pTexture);
        }