Example #1
0
 public static CCBMFontConfiguration Create(string fntFile)
 {
     CCBMFontConfiguration fontConfig = new CCBMFontConfiguration();
     if (fontConfig._initWithString(fntFile))
         return fontConfig;
     return null;
 }
Example #2
0
        protected virtual bool InitWithString(string text, string fontFile, CCSize dimentions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, CCPoint imageOffset, CCTexture2D texture)
        {
            if (string.IsNullOrEmpty(fontFile) == false)
            {
                CCBMFontConfiguration newConfig = _fontConfigLoad(fontFile);
                if (newConfig == null)
                    return false;

                this._fontConfig = newConfig;
                //this._fontFile = fontFile;

                if (texture == null)
                {
                    //base.Texture = CCTextureCache.SharedTextureCache.AddImage(this._configuration.AtlasName);
                    texture = Factory.CreateTexture(this._fontConfig.AtlasName);
                }
            }
            else
            {
                texture = new CCTexture2D();
            }

            if (text == null) text = "";
            if (base.InitWithTexture(texture, text.Length))
            {
                this._dimensions = dimentions;
                this._horizontalAlignment = hAlignment;
                this._verticalAlignment = vAlignment;

                this._displayedOpacity = this._realOpacity = 255;
                this._displayedColor = this._realColor = CCTypes.CCWhite;
                this._isCascadeOpacityEnabled = true;
                this._isCascadeColorEnabled = true;
                base.ContentSize = CCSize.Zero;
                this._isOpacityModifyRGB = base.TextureAtlas.Texture.HasPremultipliedAlpha;
                this.AnchorPoint = new CCPoint(0.5f, 0.5f);
                this._imageOffset = imageOffset;
                this._reusedChar = new CCSprite();
                this._reusedChar.InitWithTexture(base.TextureAtlas.Texture, CCRect.Zero, false);
                this._reusedChar.BatchNode = this;
                this.SetString(text, true);
                return true;
            }
            return false;
        }