Merge pull request #4097 from Cirras/atlas-to-spritesheet-trimming

Improved trim handling for Spritesheets created from trimmed Texture Atlas Frames
This commit is contained in:
Richard Davey 2018-10-19 13:38:24 +01:00 committed by GitHub
commit e9b22500c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -117,27 +117,33 @@ var SpriteSheetFromAtlas = function (texture, frame, config)
{
var destX = (leftRow) ? leftPad : 0;
var destY = (topRow) ? topPad : 0;
var destWidth = frameWidth;
var destHeight = frameHeight;
var trimWidth = 0;
var trimHeight = 0;
if (leftRow)
{
destWidth = leftWidth;
trimWidth += (frameWidth - leftWidth);
}
else if (rightRow)
if (rightRow)
{
destWidth = rightWidth;
trimWidth += (frameWidth - rightWidth);
}
if (topRow)
{
destHeight = topHeight;
trimHeight += (frameHeight - topHeight);
}
else if (bottomRow)
if (bottomRow)
{
destHeight = bottomHeight;
trimHeight += (frameHeight - bottomHeight);
}
var destWidth = frameWidth - trimWidth;
var destHeight = frameHeight - trimHeight;
sheetFrame.cutWidth = destWidth;
sheetFrame.cutHeight = destHeight;
@ -152,7 +158,7 @@ var SpriteSheetFromAtlas = function (texture, frame, config)
}
else if (rightRow)
{
frameX += rightRow;
frameX += rightWidth;
}
else
{