new TileObject( [init])
A basic tile object definition.
A basic tile object definition.
While tile layers are very suitable for anything repetitive aligned to the tile grid, sometimes you want to annotate your map with other information, not necessarily aligned to the grid. Hence the objects have their coordinates and size in pixels, but you can still easily align that to the grid when you want to.
You generally use objects to add custom information to your tile map, such as spawn points, warps, exits, etc.
When the object has a gid set, then it is represented by the image of the tile with that global ID. The image alignment currently depends on the map orientation. In orthogonal orientation it's aligned to the bottom-left while in isometric it's aligned to the bottom-center.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
init |
Object |
<optional> |
A generic object containing properties with which to populate the newly instance. If this argument is null, it is ignored. |
Extends
Members
-
ellipse :boolean
-
Used to mark an object as an ellipse. The existing
x
,y
,width
andheight
attributes are used to determine the size of the ellipse.Type:
- boolean
- Default Value:
-
- false
-
gid
-
A reference to a tile (optional).
-
height :number
-
The height of the object, in pixels.
Type:
- number
- Default Value:
-
- 0
-
id
-
Unique ID of the object. Each object that is placed on a map gets a unique id. Even if an object was deleted, no object gets the same ID. Can not be changed in Tiled Qt. (since Tiled 0.11)
-
name :string
-
The name of the object. An arbitrary string.
Type:
- string
- Default Value:
-
- null
-
polygon :graphics.geom.Polygon
-
Each polygon object is made up of a space-delimited list of x,y coordinates. The origin for these coordinates is the location of the parent object. By default, the first point is created as 0,0 denoting that the point will originate exactly where the object is placed. This object contains a list of x,y coordinates in pixels.
Type:
- Default Value:
-
- null
-
polyline :graphics.geom.Polygon
-
A polyline follows the same placement definition as a polygon object. This object contains a list of x,y coordinates in pixels.
Type:
- Default Value:
-
- null
-
rotation :number
-
The rotation of the object in degrees clockwise (default to 0). (since 0.10)
Type:
- number
- Default Value:
-
- 0
-
type :string
-
The type of the object. An arbitrary string.
Type:
- string
- Default Value:
-
- null
-
visible :boolean
-
Whether the object is shown (
true
) or hidden (false
). Defaults totrue
. (since 0.9)Type:
- boolean
- Default Value:
-
- true
-
width :number
-
The width of the object, in pixels.
Type:
- number
- Default Value:
-
- 0
-
x :number
-
The x coordinate of the object in pixels.
Type:
- number
- Default Value:
-
- 0
-
y :number
-
The y coordinate of the object in pixels.
Type:
- number
- Default Value:
-
- 0
Methods
-
clone()
-
Returns a shallow copy of the object.
- Inherited From:
Returns:
a shallow copy of the object.
-
setTo(init)
-
Sets the members of the object to the specified values.
Parameters:
Name Type Description init
Object The generic object to initialize the object.
- Inherited From:
Returns:
The current object reference.
-
toObject()
-
Returns the Object representation of this object.
- Overrides:
Returns:
the Object representation of this object.
-
toString()
-
Returns the string representation of this object.
- Inherited From:
Returns:
the string representation of this object.