public void LoadX(string sname, PList plist, int format) { name = sname; //frame = TPAtlas.StrToRect(plist["frame"] as string); //offset = TPAtlas.StrToVec2(plist["offset"] as string); //sourceColorRect = TPAtlas.StrToRect(plist["sourceColorRect"] as string); //sourceSize = TPAtlas.StrToVec2(plist["sourceSize"] as string); if (format == 2) { object varCheck; if (plist.TryGetValue("frame", out varCheck)) { frame = TPAtlas.StrToRect(plist["frame"] as string); offset = TPAtlas.StrToVec2(plist["offset"] as string); //sourceColorRect = TPAtlas.StrToRect(plist["sourceColorRect"] as string); sourceSize = TPAtlas.StrToVec2(plist["sourceSize"] as string); rotated = TPAtlas.ToBool(plist["rotated"]); } else { frame = TPAtlas.StrToRect(plist["textureRect"] as string); offset = TPAtlas.StrToVec2(plist["spriteOffset"] as string); //sourceColorRect = TPAtlas.StrToRect(plist["sourceColorRect"] as string); sourceSize = TPAtlas.StrToVec2(plist["spriteSourceSize"] as string); rotated = TPAtlas.ToBool(plist["rotated"]); } } else { //0 var x = float.Parse(plist["x"].ToString()); var y = float.Parse(plist["y"].ToString()); var w = float.Parse(plist["width"].ToString()); var h = float.Parse(plist["height"].ToString()); var ow = float.Parse(plist["originalWidth"].ToString()); var oh = float.Parse(plist["originalHeight"].ToString()); var offx = float.Parse(plist["offsetX"].ToString()); var offy = float.Parse(plist["offsetY"].ToString()); frame = new Rect(x, y, w, h); offset = new Vector2(offx, offy); //sourceColorRect = new Rect(0, 0, ow, oh); sourceSize = new Vector2(ow, oh); rotated = TPAtlas.ToBool(plist["rotated"]); } }
public void LoadX(string sname, PList plist) { name = sname; //frame = TPAtlas.StrToRect(plist["frame"] as string); //offset = TPAtlas.StrToVec2(plist["offset"] as string); //sourceColorRect = TPAtlas.StrToRect(plist["sourceColorRect"] as string); //sourceSize = TPAtlas.StrToVec2(plist["sourceSize"] as string); object varCheck; if (plist.TryGetValue("frame", out varCheck)) { frame = TPAtlas.StrToRect(plist["frame"] as string); offset = TPAtlas.StrToVec2(plist["offset"] as string); sourceColorRect = TPAtlas.StrToRect(plist["sourceColorRect"] as string); sourceSize = TPAtlas.StrToVec2(plist["sourceSize"] as string); } else { int x = (int)plist["x"]; int y = (int)plist["y"]; int w = (int)plist["width"]; int h = (int)plist["height"]; frame = new Rect(x, y, w, h); float offsetx = (float)plist["offsetX"]; float offsety = (float)plist["offsetY"]; offset = new Vector2(offsetx, offsety); int originalWidth = (int)plist["originalWidth"]; int originalHeight = (int)plist["originalHeight"]; sourceSize = new Vector2(originalWidth, originalHeight); } //else //{ // frame = TPAtlas.StrToRect(plist["textureRect"] as string); // offset = TPAtlas.StrToVec2(plist["spriteOffset"] as string); // sourceColorRect = TPAtlas.StrToRect(plist["sourceColorRect"] as string); // sourceSize = TPAtlas.StrToVec2(plist["spriteSourceSize"] as string); //} Rect rect = new Rect(frame.x, texture.height - frame.y - frame.height, frame.width, frame.height);//这里原点在左下角,y相反 sprite = Sprite.Create(texture, rect, new Vector2(0.5f, 0.5f)); }
public void LoadX(string sname, PList plist) { name = sname; //frame = TPAtlas.StrToRect(plist["frame"] as string); //offset = TPAtlas.StrToVec2(plist["offset"] as string); //sourceColorRect = TPAtlas.StrToRect(plist["sourceColorRect"] as string); //sourceSize = TPAtlas.StrToVec2(plist["sourceSize"] as string); object varCheck; if (plist.TryGetValue("frame", out varCheck)) { frame = TPAtlas.StrToRect(plist["frame"] as string); offset = TPAtlas.StrToVec2(plist["offset"] as string); sourceColorRect = TPAtlas.StrToRect(plist["sourceColorRect"] as string); sourceSize = TPAtlas.StrToVec2(plist["sourceSize"] as string); } else { frame = TPAtlas.StrToRect(plist["textureRect"] as string); offset = TPAtlas.StrToVec2(plist["spriteOffset"] as string); sourceColorRect = TPAtlas.StrToRect(plist["sourceColorRect"] as string); sourceSize = TPAtlas.StrToVec2(plist["spriteSourceSize"] as string); } }