直接上代码好了……
textureSplit[img_, plist_] := Module[
{tex, xml, sprites},
tex = Import[img];
xml = Import[plist, "XML"];
sprites =
sprites = {#[[1]], ToExpression[#[[2]]], #[[3]] == "true"} & /@
SequenceCases[
xml[[2, 3, 1, 3, 2, 3]], {XMLElement["key", {}, {path_}],
XMLElement[
"dict", {}, {XMLElement["key", {}, {"aliases"}],
XMLElement["array", {}, {}],
XMLElement["key", {}, {"spriteOffset"}],
XMLElement["string", {}, {_}],
XMLElement["key", {}, {"spriteSize"}],
XMLElement["string", {}, {_}],
XMLElement["key", {}, {"spriteSourceSize"}],
XMLElement["string", {}, {_}],
XMLElement["key", {}, {"textureRect"}],
XMLElement["string", {}, {rect_}],
XMLElement["key", {}, {"textureRotated"}],
XMLElement[rotated_, {}, {}]}]} :> {path, rect, rotated},
Infinity];
{#[[1]], (ImageRotate[
ImageTake @@ (Join[{tex}, ({{#[[1, 1]], #[[1, 2]] - 1}, {#[[
2, 1]], #[[2, 2]] - 1}} &)@
Reverse@
Transpose[{#[[1]], #[[1]] +
If[#2, Reverse[#[[2]]], #[[2]]]}]]),
If[#2, 90 Degree, 0]] &)[#[[2]], #[[3]]]} & /@ sprites
]
textureSplit[img_] :=
textureSplit[img,
DirectoryName[img] <> FileBaseName[img] <> ".plist"]