mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
Removed TextureAtlas operations from newRegionAttachment and newMeshAttachment.
This commit is contained in:
parent
1535906511
commit
edc756507d
@ -59,11 +59,11 @@ package spine.starling {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function newRegionAttachment(skin : Skin, name : String, path : String) : RegionAttachment {
|
public function newRegionAttachment(skin : Skin, name : String, path : String) : RegionAttachment {
|
||||||
var texture : Texture = getTexture(path);
|
var texture : SubTexture = getTexture(path) as SubTexture;//atlas.getTexture() method always return type of SubTexture
|
||||||
if (texture == null)
|
if (texture == null)
|
||||||
throw new Error("Region not found in Starling atlas: " + path + " (region attachment: " + name + ")");
|
throw new Error("Region not found in Starling atlas: " + path + " (region attachment: " + name + ")");
|
||||||
var attachment : RegionAttachment = new RegionAttachment(name);
|
var attachment : RegionAttachment = new RegionAttachment(name);
|
||||||
var rotated : Boolean = atlas.getRotation(path);
|
var rotated : Boolean = texture.rotated;//if texture == null you trhow exception, that is why atlas.getRotation() method always return texture.rotated.
|
||||||
attachment.rendererObject = new Image(Texture.fromTexture(texture)); // Discard frame.
|
attachment.rendererObject = new Image(Texture.fromTexture(texture)); // Discard frame.
|
||||||
var frame : Rectangle = texture.frame;
|
var frame : Rectangle = texture.frame;
|
||||||
attachment.regionOffsetX = frame ? -frame.x : 0;
|
attachment.regionOffsetX = frame ? -frame.x : 0;
|
||||||
@ -79,59 +79,58 @@ package spine.starling {
|
|||||||
tmp = attachment.regionWidth;
|
tmp = attachment.regionWidth;
|
||||||
attachment.regionWidth = attachment.regionHeight;
|
attachment.regionWidth = attachment.regionHeight;
|
||||||
attachment.regionHeight = tmp;
|
attachment.regionHeight = tmp;
|
||||||
|
attachment["regionU2"] = 0;
|
||||||
|
attachment["regionV2"] = 1;
|
||||||
|
attachment["regionU"] = 1;
|
||||||
|
attachment["regionV"] = 0;
|
||||||
|
}else{
|
||||||
|
attachment["regionU"] = 0;
|
||||||
|
attachment["regionV"] = 0;
|
||||||
|
attachment["regionU2"] = 1;
|
||||||
|
attachment["regionV2"] = 1;
|
||||||
}
|
}
|
||||||
if (!rotated) {
|
attachment.setUVs(attachment["regionU"], attachment["regionV"], attachment["regionU2"], attachment["regionV2"], rotated);
|
||||||
attachment["regionU"] = 0;
|
|
||||||
attachment["regionV"] = 0;
|
|
||||||
attachment["regionU2"] = 1;
|
|
||||||
attachment["regionV2"] = 1;
|
|
||||||
} else {
|
|
||||||
attachment["regionU2"] = 0;
|
|
||||||
attachment["regionV2"] = 1;
|
|
||||||
attachment["regionU"] = 1;
|
|
||||||
attachment["regionV"] = 0;
|
|
||||||
}
|
|
||||||
attachment.setUVs(attachment["regionU"], attachment["regionV"], attachment["regionU2"], attachment["regionV2"], atlas.getRotation(path));
|
|
||||||
return attachment;
|
return attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newMeshAttachment(skin : Skin, name : String, path : String) : MeshAttachment {
|
public function newMeshAttachment(skin : Skin, name : String, path : String) : MeshAttachment {
|
||||||
var texture : Texture = getTexture(path);
|
var texture : SubTexture = getTexture(path) as SubTexture;
|
||||||
if (texture == null)
|
if (texture == null)
|
||||||
throw new Error("Region not found in Starling atlas: " + path + " (mesh attachment: " + name + ")");
|
throw new Error("Region not found in Starling atlas: " + path + " (mesh attachment: " + name + ")");
|
||||||
var rotated : Boolean = atlas.getRotation(path);
|
var rotated : Boolean =texture.rotated;
|
||||||
var attachment : MeshAttachment = new MeshAttachment(name);
|
var attachment : MeshAttachment = new MeshAttachment(name);
|
||||||
attachment.regionRotate = rotated;
|
attachment.regionRotate = rotated;
|
||||||
attachment.rendererObject = new Image(Texture.fromTexture(texture)); // Discard frame.
|
attachment.rendererObject = new Image(Texture.fromTexture(texture)); // Discard frame.
|
||||||
var subTexture : SubTexture = texture as SubTexture;
|
// var subTexture : SubTexture = texture as SubTexture;
|
||||||
if (subTexture) {
|
// if (subTexture) {//subTexture can't be null (line 99)
|
||||||
var root : Texture = subTexture.root;
|
var root : Texture = texture.root;
|
||||||
var rectRegion : Rectangle = atlas.getRegion(path);
|
var rectRegion : Rectangle = atlas.getRegion(path);
|
||||||
if (!rotated) {
|
if (!rotated) {
|
||||||
attachment.regionU = rectRegion.x / root.width;
|
attachment.regionU = rectRegion.x / root.width;
|
||||||
attachment.regionV = rectRegion.y / root.height;
|
attachment.regionV = rectRegion.y / root.height;
|
||||||
attachment.regionU2 = (rectRegion.x + subTexture.width) / root.width;
|
attachment.regionU2 = (rectRegion.x + texture.width) / root.width;
|
||||||
attachment.regionV2 = (rectRegion.y + subTexture.height) / root.height;
|
attachment.regionV2 = (rectRegion.y + texture.height) / root.height;
|
||||||
} else {
|
} else {
|
||||||
attachment.regionU2 = rectRegion.x / root.width;
|
attachment.regionU2 = rectRegion.x / root.width;
|
||||||
attachment.regionV2 = rectRegion.y / root.height;
|
attachment.regionV2 = rectRegion.y / root.height;
|
||||||
attachment.regionU = (rectRegion.x + subTexture.height) / root.width;
|
attachment.regionU = (rectRegion.x + texture.height) / root.width;
|
||||||
attachment.regionV = (rectRegion.y + subTexture.width) / root.height;
|
attachment.regionV = (rectRegion.y + texture.width) / root.height;
|
||||||
}
|
}
|
||||||
attachment.rendererObject = new Image(root);
|
attachment.rendererObject = new Image(root);
|
||||||
} else {
|
// } else {
|
||||||
if (!rotated) {
|
//Code never reached to here. if subTextre==null you throw exception.
|
||||||
attachment.regionU = 0;
|
// if (!rotated) {
|
||||||
attachment.regionV = 1;
|
// attachment.regionU = 0;
|
||||||
attachment.regionU2 = 1;
|
// attachment.regionV = 1;
|
||||||
attachment.regionV2 = 0;
|
// attachment.regionU2 = 1;
|
||||||
} else {
|
// attachment.regionV2 = 0;
|
||||||
attachment.regionU2 = 0;
|
// } else {
|
||||||
attachment.regionV2 = 1;
|
// attachment.regionU2 = 0;
|
||||||
attachment.regionU = 1;
|
// attachment.regionV2 = 1;
|
||||||
attachment.regionV = 0;
|
// attachment.regionU = 1;
|
||||||
}
|
// attachment.regionV = 0;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
var frame : Rectangle = texture.frame;
|
var frame : Rectangle = texture.frame;
|
||||||
attachment.regionOffsetX = frame ? -frame.x : 0;
|
attachment.regionOffsetX = frame ? -frame.x : 0;
|
||||||
attachment.regionOffsetY = frame ? -frame.y : 0;
|
attachment.regionOffsetY = frame ? -frame.y : 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user