Skip to content

Commit 4b011e2

Browse files
authored
Merge pull request #5790 from samme/fix/createFromObjects-offset
Fix offset for non-tile objects in createFromObjects()
2 parents a4f6ace + 788bcb4 commit 4b011e2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/tilemaps/Tilemap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,11 +802,11 @@ var Tilemap = new Class({
802802
sprite.displayHeight = obj.height;
803803
}
804804

805-
// Origin is (0, 1) in Tiled, so find the offset that matches the Sprites origin.
805+
// Origin is (0, 1) for tile objects or (0, 0) for other objects in Tiled, so find the offset that matches the Sprites origin.
806806
// Do not offset objects with zero dimensions (e.g. points).
807807
var offset = {
808808
x: sprite.originX * obj.width,
809-
y: (sprite.originY - 1) * obj.height
809+
y: (sprite.originY - (obj.gid ? 1 : 0)) * obj.height
810810
};
811811

812812
// If the object is rotated, then the origin offset also needs to be rotated.

0 commit comments

Comments
 (0)