class DragonSkeleton::Tilemap::Cell
A single cell in a tilemap.
A cell is an Array with the following values which are also available as attributes:
-
[0]
x
(read-only) -
[1]
y
(read-only) -
[2]
path
-
[3]
r
-
[4]
g
-
[5]
b
-
[6]
a
-
[7]
tile_x
-
[8]
tile_y
-
[9]
tile_w
-
[10]
tile_h
-
[11]
tile
: The key of the tile to use for this cell
If the Tilemap
has a tileset, setting the tile
attribute will also update the other attributes according to the values returned by the tileset.
Public Class Methods
property_index(name)
click to toggle source
Returns the index of the given property.
# File lib/dragon_skeleton/tilemap/cell.rb, line 34 def self.property_index(name) @property_indexes[name] end
Public Instance Methods
assign(values)
click to toggle source
Assigns the given values to the cell.
Example:
cell.assign(path: 'sprites/box.png', r: 255, g: 0, b: 0)
# File lib/dragon_skeleton/tilemap/cell.rb, line 71 def assign(values) values.each do |name, value| index = Cell.property_index(name) next unless index self[index] = value end end