class DXRuby::Tiled::Tile

Attributes

adjusted_offset_y[R]
angle[R]
collision[RW]
collision_enable[RW]
image[R]
offset_x[R]
offset_y[R]
original_image[R]
scale_x[R]
scale_y[R]
tileset[R]
type[RW]

Public Class Methods

new(image, offset_x, offset_y, adjusted_offset_y, tileset = nil) click to toggle source
# File lib/dxruby_tiled/tile.rb, line 8
def initialize(image, offset_x, offset_y, adjusted_offset_y, tileset = nil)
  @image = @original_image = image
  @offset_x = offset_x
  @offset_y = offset_y
  @adjusted_offset_y = adjusted_offset_y
  @tileset = tileset
  @type = nil
  @anim_time_total = 1
  @anim_time = [0]
  @anim_tile = [self]
  @collision = nil
  @collision_enable = true
  @scale_x = 1
  @scale_y = 1
  @angle   = 0
end

Public Instance Methods

animate(current_time) click to toggle source
# File lib/dxruby_tiled/tile.rb, line 33
def animate(current_time)
  time = current_time % @anim_time_total
  @anim_tile[@anim_time.rindex { |t| time >= t } ]
end
animate!(current_time) click to toggle source
# File lib/dxruby_tiled/tile.rb, line 38
def animate!(current_time)
  time = current_time % @anim_time_total
  tile = @anim_tile[@anim_time.rindex { |t| time >= t } ]
  @image    = tile.original_image
  @offset_x = tile.offset_x
  @offset_y = tile.offset_y
  @adjusted_offset_y = tile.adjusted_offset_y
end
draw(x, y, target = DXRuby::Window, z_index = 0)
Alias for: render
height() click to toggle source
# File lib/dxruby_tiled/tile.rb, line 26
def height; @image.height; end
render(x, y, target = DXRuby::Window, z_index = 0) click to toggle source
# File lib/dxruby_tiled/tile.rb, line 28
def render(x, y, target = DXRuby::Window, z_index = 0)
  target.draw(x + @offset_x, y + @adjusted_offset_y, @image, z_index)
end
Also aliased as: draw
set_animation(anim_time, anim_tile) click to toggle source
# File lib/dxruby_tiled/tile.rb, line 47
def set_animation(anim_time, anim_tile)
  @anim_time = anim_time
  @anim_tile = anim_tile
  @anim_time_total = @anim_time.pop
end
to_sprite(x, y) click to toggle source
# File lib/dxruby_tiled/tile.rb, line 53
def to_sprite(x, y)
  TileObject.new(x: x, y: y, tile: self)
end
width() click to toggle source
# File lib/dxruby_tiled/tile.rb, line 25
def width ; @image.width ; end