public MTexture(MTexture parent, string atlasPath, Rectangle clipRect) : this(parent, clipRect) { AtlasPath = atlasPath; }
public MTexture(MTexture parent, Rectangle clipRect) : this(parent, clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height) { }
public Image(MTexture texture) : base(false) { Texture = texture; }
internal Image(MTexture texture, bool active) : base(active) { Texture = texture; }
public Spritesheet(MTexture texture, int frameWidth, int frameHeight, int frameSep = 0) : base(texture, true) { SetFrames(texture, frameWidth, frameHeight, frameSep); animations = new Dictionary <T, Animation>(); }
public PixelFontSize AddFontSize(string path, XmlElement data, Atlas atlas = null, bool outline = false) { // check if size already exists var size = data["info"].AttrFloat("size"); foreach (var fs in Sizes) { if (fs.Size == size) { return(fs); } } // get textures Textures = new List <MTexture>(); var pages = data["pages"]; foreach (XmlElement page in pages) { var file = page.Attr("file"); var atlasPath = Path.GetFileNameWithoutExtension(file); if (atlas != null && atlas.Has(atlasPath)) { Textures.Add(atlas[atlasPath]); } else { var dir = Path.GetDirectoryName(path); dir = dir.Substring(Engine.ContentDirectory.Length + 1); Textures.Add(MTexture.FromFile(Path.Combine(dir, file))); } } // create font size var fontSize = new PixelFontSize() { Textures = Textures, Characters = new Dictionary <int, PixelFontCharacter>(), LineHeight = data["common"].AttrInt("lineHeight"), Size = size, Outline = outline }; // get characters foreach (XmlElement character in data["chars"]) { int id = character.AttrInt("id"); int page = character.AttrInt("page", 0); fontSize.Characters.Add(id, new PixelFontCharacter(id, Textures[page], character)); } // get kerning if (data["kernings"] != null) { foreach (XmlElement kerning in data["kernings"]) { var from = kerning.AttrInt("first"); var to = kerning.AttrInt("second"); var push = kerning.AttrInt("amount"); PixelFontCharacter c = null; if (fontSize.Characters.TryGetValue(from, out c)) { c.Kerning.Add(to, push); } } } // add font size Sizes.Add(fontSize); Sizes.Sort((a, b) => { return(Math.Sign(a.Size - b.Size)); }); return(fontSize); }