public AsTextureAtlas(AsTexture texture, AsXML atlasXml)
 {
     mTextureRegions = new AsDictionary();
     mTextureFrames = new AsDictionary();
     mAtlasTexture = texture;
     if(atlasXml != null)
     {
         parseAtlasXml(atlasXml);
     }
 }
 public AsBitmapFont(AsTexture texture, AsXML fontXml)
 {
     if(texture == null && fontXml == null)
     {
         texture = AsMiniBitmapFont.getTexture();
         fontXml = AsMiniBitmapFont.getXml();
     }
     mName = "unknown";
     mLineHeight = mSize = mBaseline = 14;
     mTexture = texture;
     mChars = new AsDictionary();
     mHelperImage = new AsImage(texture);
     mCharLocationPool = new AsVector<AsCharLocation>();
     if(fontXml != null)
     {
         parseFontXml(fontXml);
     }
 }
 private void parseFontXml(AsXML fontXml)
 {
     float scale = mTexture.getScale();
     AsRectangle frame = mTexture.getFrame();
     mName = fontXml.elements("info").attribute("face");
     mSize = AsGlobal.parseFloat(fontXml.elements("info").attribute("size")) / scale;
     mLineHeight = AsGlobal.parseFloat(fontXml.elements("common").attribute("lineHeight")) / scale;
     mBaseline = AsGlobal.parseFloat(fontXml.elements("common").attribute("base")) / scale;
     if(fontXml.elements("info").attribute("smooth").ToString() == "0")
     {
         setSmoothing(AsTextureSmoothing.NONE);
     }
     if(mSize <= 0)
     {
         AsGlobal.trace("[Starling] Warning: invalid font size in '" + mName + "' font.");
         mSize = mSize == 0.0f ? 16.0f : mSize * -1.0f;
     }
     AsXMLList __charElements_ = fontXml.elements("chars").elements("_char");
     if (__charElements_ != null)
     {
         foreach (AsXML charElement in __charElements_)
         {
             int id = (int)(AsGlobal.parseInt(charElement.attribute("id")));
             float xOffset = AsGlobal.parseFloat(charElement.attribute("xoffset")) / scale;
             float yOffset = AsGlobal.parseFloat(charElement.attribute("yoffset")) / scale;
             float xAdvance = AsGlobal.parseFloat(charElement.attribute("xadvance")) / scale;
             AsRectangle region = new AsRectangle();
             region.x = AsGlobal.parseFloat(charElement.attribute("x")) / scale + frame.x;
             region.y = AsGlobal.parseFloat(charElement.attribute("y")) / scale + frame.y;
             region.width = AsGlobal.parseFloat(charElement.attribute("width")) / scale;
             region.height = AsGlobal.parseFloat(charElement.attribute("height")) / scale;
             AsTexture texture = AsTexture.fromTexture(mTexture, region);
             AsBitmapChar bitmapChar = new AsBitmapChar(id, texture, xOffset, yOffset, xAdvance);
             addChar(id, bitmapChar);
         }
     }
     AsXMLList __kerningElements_ = fontXml.elements("kernings").elements("kerning");
     if (__kerningElements_ != null)
     {
         foreach (AsXML kerningElement in __kerningElements_)
         {
             int first = (int)(AsGlobal.parseInt(kerningElement.attribute("first")));
             int second = (int)(AsGlobal.parseInt(kerningElement.attribute("second")));
             float amount = AsGlobal.parseFloat(kerningElement.attribute("amount")) / scale;
             if(mChars.containsKey(second))
             {
                 getChar(second).addKerning(first, amount);
             }
         }
     }
 }
Пример #4
0
 public static void disposeXML(AsXML node)
 {
     throw new AsNotImplementedError();
 }
Пример #5
0
 public virtual AsXML appendChild(AsXML child)
 {
     mElements.push(child);
     return(child);
 }
 protected virtual void parseAtlasXml(AsXML atlasXml)
 {
     float scale = mAtlasTexture.getScale();
     AsSubTexture __subTextures_ = atlasXml.SubTexture;
     if (__subTextures_ != null)
     {
         foreach (AsXML subTexture in __subTextures_)
         {
             String name = subTexture.attribute("name");
             float x = AsGlobal.parseFloat(subTexture.attribute("x")) / scale;
             float y = AsGlobal.parseFloat(subTexture.attribute("y")) / scale;
             float width = AsGlobal.parseFloat(subTexture.attribute("width")) / scale;
             float height = AsGlobal.parseFloat(subTexture.attribute("height")) / scale;
             float frameX = AsGlobal.parseFloat(subTexture.attribute("frameX")) / scale;
             float frameY = AsGlobal.parseFloat(subTexture.attribute("frameY")) / scale;
             float frameWidth = AsGlobal.parseFloat(subTexture.attribute("frameWidth")) / scale;
             float frameHeight = AsGlobal.parseFloat(subTexture.attribute("frameHeight")) / scale;
             AsRectangle region = new AsRectangle(x, y, width, height);
             AsRectangle frame = frameWidth > 0 && frameHeight > 0 ? new AsRectangle(frameX, frameY, frameWidth, frameHeight) : null;
             addRegion(name, region, frame);
         }
     }
 }
Пример #7
0
 public virtual AsXML appendChild(AsXML child)
 {
     mElements.push(child);
     return child;
 }
Пример #8
0
 public override bc.flash.xml.AsXML appendChild(bc.flash.xml.AsXML child)
 {
     return(mChildren.appendChild(child));
 }
Пример #9
0
 public virtual AsXML appendChild(AsXML child)
 {
     return(child);
 }
Пример #10
0
 public override AsXML appendChild(AsXML child)
 {
     return mChildren.appendChild(child);
 }
Пример #11
0
 public virtual AsXML appendChild(AsXML child)
 {
     return child;
 }