Class: RETMX::Map::TileSet

Inherits:
Object
  • Object
show all
Defined in:
lib/retmx.rb

Defined Under Namespace

Classes: Image, Tile

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#firstgidObject (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

#imageObject (readonly)

Image has



407
408
409
# File 'lib/retmx.rb', line 407

def image
  @image
end

#mapObject (readonly)

Map belongs



413
414
415
# File 'lib/retmx.rb', line 413

def map
  @map
end

#marginObject (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

#nameObject (readonly)

The name of this tileset.



392
393
394
# File 'lib/retmx.rb', line 392

def name
  @name
end

#propertyObject (readonly)

Properties



410
411
412
# File 'lib/retmx.rb', line 410

def property
  @property
end

#sourceObject (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

#spacingObject (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

#tileheightObject (readonly)

The (maximum) height of the tiles in this tileset.



398
399
400
# File 'lib/retmx.rb', line 398

def tileheight
  @tileheight
end

#tilewidthObject (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