Class: RETMX::Map::TileSet
- Inherits:
-
Object
- Object
- RETMX::Map::TileSet
- Defined in:
- lib/retmx.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#firstgid ⇒ Object
readonly
The first global tile ID of this tileset (this global ID maps to the first tile in this tileset).
-
#image ⇒ Object
readonly
Image has.
-
#map ⇒ Object
readonly
Map belongs.
-
#margin ⇒ Object
readonly
The margin around the tiles in this tileset (applies to the tileset image).
-
#name ⇒ Object
readonly
The name of this tileset.
-
#property ⇒ Object
readonly
Properties.
-
#source ⇒ Object
readonly
If this tileset is stored in an external TSX (Tile Set XML) file, this attribute refers to that file.
-
#spacing ⇒ Object
readonly
The spacing in pixels between the tiles in this tileset (applies to the tileset image).
-
#tileheight ⇒ Object
readonly
The (maximum) height of the tiles in this tileset.
-
#tilewidth ⇒ Object
readonly
The (maximum) width of the tiles in this tileset.
Instance Method Summary collapse
-
#at(i) ⇒ Object
Get tile at index
i
. -
#initialize(map, xml) ⇒ TileSet
constructor
A new instance of TileSet.
Constructor Details
#initialize(map, xml) ⇒ TileSet
Returns a new instance of TileSet.
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
# File 'lib/retmx.rb', line 414 def initialize(map, xml) @map = map @firstgid = xml.attributes['firstgid'].to_i @source = xml.attributes['source'] @name = xml.attributes['name'] @tilewidth = xml.attributes['tilewidth'].to_i @tileheight = xml.attributes['tileheight'].to_i @spacing = xml.attributes['spacing'].nil? ? 0 : xml.attributes['spacing'].to_i @margin = xml.attributes['margin'].nil? ? 0 : xml.attributes['margin'].to_i @image = nil #array of Recs that know how cut a image @tiles = [] build(xml) end |
Instance Attribute Details
#firstgid ⇒ Object (readonly)
The first global tile ID of this tileset (this global ID maps to the first tile in this tileset).
386 387 388 |
# File 'lib/retmx.rb', line 386 def firstgid @firstgid end |
#image ⇒ Object (readonly)
Image has
407 408 409 |
# File 'lib/retmx.rb', line 407 def image @image end |
#map ⇒ Object (readonly)
Map belongs
413 414 415 |
# File 'lib/retmx.rb', line 413 def map @map end |
#margin ⇒ Object (readonly)
The margin around the tiles in this tileset (applies to the tileset image).
404 405 406 |
# File 'lib/retmx.rb', line 404 def margin @margin end |
#name ⇒ Object (readonly)
The name of this tileset.
392 393 394 |
# File 'lib/retmx.rb', line 392 def name @name end |
#property ⇒ Object (readonly)
Properties
410 411 412 |
# File 'lib/retmx.rb', line 410 def property @property end |
#source ⇒ Object (readonly)
If this tileset is stored in an external TSX (Tile Set XML) file, this attribute refers to that file.
389 390 391 |
# File 'lib/retmx.rb', line 389 def source @source end |
#spacing ⇒ Object (readonly)
The spacing in pixels between the tiles in this tileset (applies to the tileset image).
401 402 403 |
# File 'lib/retmx.rb', line 401 def spacing @spacing end |
#tileheight ⇒ Object (readonly)
The (maximum) height of the tiles in this tileset.
398 399 400 |
# File 'lib/retmx.rb', line 398 def tileheight @tileheight end |
#tilewidth ⇒ Object (readonly)
The (maximum) width of the tiles in this tileset.
395 396 397 |
# File 'lib/retmx.rb', line 395 def tilewidth @tilewidth end |
Instance Method Details
#at(i) ⇒ Object
Get tile at index i
432 433 434 435 |
# File 'lib/retmx.rb', line 432 def at(i) return @tiles[i.gid] if i.respond_to? :gid return @tiles[i] end |