Fix simple sprite rendering issue with rotated frame

This commit is contained in:
pandamicro
2018-02-24 15:04:15 +08:00
parent 04f47b6466
commit 0afc0e9e12
@@ -55,12 +55,12 @@ module.exports = {
texh = texture._height;
let frame = sprite.spriteFrame;
let rect = frame._rect;
let l = texw === 0 ? 0 : rect.x / texw;
let r = texw === 0 ? 0 : (rect.x + rect.width) / texw;
let b = texh === 0 ? 0 : (rect.y + rect.height) / texh;
let t = texh === 0 ? 0 : rect.y / texh;
if (frame._rotated) {
let l = texw === 0 ? 0 : rect.x / texw;
let r = texw === 0 ? 0 : (rect.x + rect.height) / texw;
let b = texh === 0 ? 0 : (rect.y + rect.width) / texh;
let t = texh === 0 ? 0 : rect.y / texh;
data[0].u = l;
data[0].v = t;
data[1].u = l;
@@ -71,6 +71,10 @@ module.exports = {
data[3].v = b;
}
else {
let l = texw === 0 ? 0 : rect.x / texw;
let r = texw === 0 ? 0 : (rect.x + rect.width) / texw;
let b = texh === 0 ? 0 : (rect.y + rect.height) / texh;
let t = texh === 0 ? 0 : rect.y / texh;
data[0].u = l;
data[0].v = b;
data[1].u = r;