Skip to content

Commit

Permalink
Fix sheet dimensions changing but not updating internal sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
Jbudone committed Apr 7, 2019
1 parent 74fee7a commit deb3c73
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion resourceBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,17 @@ const processGeneratedTilesheet = (package) => {
let translated = true;
if (translatedSprite === undefined) {
translated = false;
translatedSprite = localSprite; // Hasn't moved? No sprite here?
translatedSprite = localSprite; // Hasn't moved?

if (oldColumns !== newColumns) {
// Our bounds have changed, since sprite = row * numColumns +
// column, and numColumns have changed, need to recalc this
const spriteRow = Math.floor(localSprite / oldColumns),
spriteCol = localSprite - (spriteRow * oldColumns),
newSpriteLocal = spriteRow * newColumns + spriteCol;

translatedSprite = newSpriteLocal;
}

} else if (translatedSprite === null) {
translated = false;
Expand Down Expand Up @@ -1824,6 +1834,7 @@ const processGeneratedTilesheet = (package) => {
refTileset.$.tilecount = newTilecount;
refTileset.$.columns = package.columns;
refTileset.image[0].$.width = newColumns * tilesize;
refTileset.image[0].$.height = newRows * tilesize;


if (shiftedTilesets) {
Expand Down

0 comments on commit deb3c73

Please sign in to comment.