public void _parse(string txt) { var d1 = new Date().ValueOf(); var json = JSON.Parse(txt); //parse fontinfo var font = (object[])json["font"]; this.fontname = (string)font[0]; this.pointSize = (float)font[1]; this.padding = (float)font[2]; this.lineHeight = (float)font[3]; this.baseline = (float)font[4]; this.atlasWidth = (float)font[5]; this.atlasHeight = (float)font[6]; //parse char map this.cmap = new object(); var map = json["map"]; foreach (var c in Script.GetOwnPropertyNames(map)) { var finfo = new charinfo();//ness this.cmap[c] = finfo; finfo.x = map[c].As <float[]>()[0] / this.atlasWidth; finfo.y = map[c].As <float[]>()[1] / this.atlasHeight; finfo.w = map[c].As <float[]>()[2] / this.atlasWidth; finfo.h = map[c].As <float[]>()[3] / this.atlasHeight; finfo.xSize = map[c].As <float[]>()[2]; finfo.ySize = map[c].As <float[]>()[3]; finfo.xOffset = map[c].As <float[]>()[4]; finfo.yOffset = map[c].As <float[]>()[5]; finfo.xAddvance = map[c].As <float[]>()[6]; } map = null; json = null; var d2 = new Date().ValueOf(); var n = d2 - d1; Console.WriteLine("json time=" + n); }
public void draw(spriteBatcher sb, charinfo r, spriteRect rect, spriteColor c = null, spriteColor colorBorder = null) { if (c == null) { c = spriteColor.white; } if (colorBorder == null) { colorBorder = new spriteColor(0f, 0f, 0f, 0.5f); } //if (r==null) { var p = this.pointbuf[0]; p.x = rect.x; p.y = rect.y + rect.h; p.z = 0; p.u = r.x; p.v = r.y + r.h; p.r = c.r; p.g = c.g; p.b = c.b; p.a = c.a; p.r2 = colorBorder.r; p.g2 = colorBorder.g; p.b2 = colorBorder.b; p.a2 = colorBorder.a; p = this.pointbuf[1]; p.x = rect.x + rect.w; p.y = rect.y + rect.h; p.z = 0; p.u = r.x + r.w; p.v = r.y + r.h; p.r = c.r; p.g = c.g; p.b = c.b; p.a = c.a; p.r2 = colorBorder.r; p.g2 = colorBorder.g; p.b2 = colorBorder.b; p.a2 = colorBorder.a; p = this.pointbuf[2]; p.x = rect.x; p.y = rect.y; p.z = 0; p.u = r.x; p.v = r.y; p.r = c.r; p.g = c.g; p.b = c.b; p.a = c.a; p.r2 = colorBorder.r; p.g2 = colorBorder.g; p.b2 = colorBorder.b; p.a2 = colorBorder.a; p = this.pointbuf[3]; p.x = rect.x + rect.w; p.y = rect.y; p.z = 0; p.u = r.x + r.w; p.v = r.y; p.r = c.r; p.g = c.g; p.b = c.b; p.a = c.a; p.r2 = colorBorder.r; p.g2 = colorBorder.g; p.b2 = colorBorder.b; p.a2 = colorBorder.a; } sb.setMat(this.mat); sb.addRect(this.pointbuf); }