Gid class
A Gid, Global Tile ID is a Tiled concept to represent the tiles inside int matrices. This wrapper is used by Layer and Chunk to provide more easy access to the user.
Normally the integer stored by tiled in those matrixes use bit operations to store two different elements of information:
- the actual gid, i.e., the global id of the tile on your tileset
- flip information
Each tileset tile placed in the world matrix can have arbitrary flip data. For tiled, Flip includes flips and rotation via the concept of the diagonal flip.
This class uses the documentation on tile flips below to extract that complexity from the user by using the Flips class.
Tile flipping
The highest three bits of the gid store the flipped states:
- Bit 32 is used for storing whether the tile is horizontally flipped,
- Bit 31 is used for the vertically flipped tiles and
- Bit 30 indicates whether the tile is flipped (anti) diagonally, enabling tile rotation.
These bits have to be read and cleared before you can find out which tileset a tile belongs to.
When rendering a tile, the order of operation matters. The diagonal flip (x/y axis swap) is done first, followed by the horizontal and vertical flips.
Constructors
- Gid(int tile, Flips flips)
-
const
- Gid.fromInt(int gid)
-
factory
Properties
Methods
-
copyWith(
{int? tile, Flips? flips}) → Gid -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- flippedAntiDiagonallyFlag → const int
- flippedDiagonallyFlag → const int
- flippedHorizontallyFlag → const int
- flippedVerticallyFlag → const int