Skip to content

Commit 63eb41e

Browse files
authored
Merge pull request phaserjs#5051 from samme/feature/tiled-point-and-createFromObjects
Add Tiled point object and change offset in createFromObjects()
2 parents e85a66f + 4a711e4 commit 63eb41e

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/tilemaps/Tilemap.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,9 +671,10 @@ var Tilemap = new Class({
671671
if (obj.height) { sprite.displayHeight = obj.height; }
672672

673673
// Origin is (0, 1) in Tiled, so find the offset that matches the Sprite's origin.
674+
// Do not offset objects with zero dimensions (e.g. points).
674675
var offset = {
675-
x: sprite.originX * sprite.displayWidth,
676-
y: (sprite.originY - 1) * sprite.displayHeight
676+
x: sprite.originX * obj.width,
677+
y: (sprite.originY - 1) * obj.height
677678
};
678679

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

src/tilemaps/parsers/tiled/ParseObject.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,19 @@ var ParseObject = function (tiledObject, offsetX, offsetY)
5353
else if (tiledObject.ellipse)
5454
{
5555
parsedObject.ellipse = tiledObject.ellipse;
56-
parsedObject.width = tiledObject.width;
57-
parsedObject.height = tiledObject.height;
5856
}
5957
else if (tiledObject.text)
6058
{
61-
parsedObject.width = tiledObject.width;
62-
parsedObject.height = tiledObject.height;
6359
parsedObject.text = tiledObject.text;
6460
}
61+
else if (tiledObject.point)
62+
{
63+
parsedObject.point = true;
64+
}
6565
else
6666
{
6767
// Otherwise, assume it is a rectangle
6868
parsedObject.rectangle = true;
69-
parsedObject.width = tiledObject.width;
70-
parsedObject.height = tiledObject.height;
7169
}
7270

7371
return parsedObject;

src/tilemaps/typedefs/TiledObject.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @typedef {object} Phaser.Types.Tilemaps.TiledObject
33
* @since 3.0.0
4-
*
4+
*
55
* @property {integer} id - The unique object ID.
66
* @property {string} name - The name this object was assigned in Tiled.
77
* @property {string} type - The type, as assigned in Tiled.
@@ -21,4 +21,5 @@
2121
* @property {any} [text] - Only set if a text object. Contains the text objects properties.
2222
* @property {boolean} [rectangle] - Only set, and set to `true`, if a rectangle object.
2323
* @property {boolean} [ellipse] - Only set, and set to `true`, if a ellipse object.
24+
* @property {boolean} [point] - Only set, and set to `true`, if a point object.
2425
*/

0 commit comments

Comments
 (0)