mirror of
https://github.com/photonstorm/phaser
synced 2024-11-17 10:18:42 +00:00
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:
commit
e9b22500c0
1 changed files with 15 additions and 9 deletions
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue