Class: DXRuby::Tiled::FlippedTile
- Inherits:
-
Object
- Object
- DXRuby::Tiled::FlippedTile
- Defined in:
- lib/dxruby_tiled/tile.rb
Instance Attribute Summary collapse
-
#angle ⇒ Object
readonly
Returns the value of attribute angle.
-
#scale_x ⇒ Object
readonly
Returns the value of attribute scale_x.
-
#scale_y ⇒ Object
readonly
Returns the value of attribute scale_y.
-
#tile ⇒ Object
readonly
Returns the value of attribute tile.
Instance Method Summary collapse
- #adjusted_offset_y ⇒ Object
- #collision ⇒ Object
- #collision=(value) ⇒ Object
- #collision_enable ⇒ Object
- #collision_enable=(value) ⇒ Object
- #height ⇒ Object
- #image ⇒ Object
-
#initialize(tile, tileid, hex = false) ⇒ FlippedTile
constructor
A new instance of FlippedTile.
- #offset_x ⇒ Object
- #offset_y ⇒ Object
- #original_image ⇒ Object
- #render(x, y, target = DXRuby::Window, z_index = 0) ⇒ Object (also: #draw)
- #tileset ⇒ Object
- #to_sprite(x, y) ⇒ Object
- #type ⇒ Object
- #type=(value) ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(tile, tileid, hex = false) ⇒ FlippedTile
Returns a new instance of FlippedTile.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/dxruby_tiled/tile.rb', line 61 def initialize(tile, tileid, hex = false) @tile = tile if hex @scale_x, @scale_y, @angle = case tileid & 0xf0000000 when 0x10000000 then [ 1, 1, 120] when 0x20000000 then [ 1, 1, 60] when 0x30000000 then [-1, -1, 0] when 0x40000000 then [ 1, -1, 0] when 0x50000000 then [-1, 1, 300] when 0x60000000 then [-1, 1, 240] when 0x70000000 then [-1, 1, 0] when 0x80000000 then [-1, 1, 0] when 0x90000000 then [-1, 1, 120] when 0xa0000000 then [-1, 1, 60] when 0xb0000000 then [ 1, -1, 0] when 0xc0000000 then [-1, -1, 0] when 0xd0000000 then [ 1, 1, 300] when 0xe0000000 then [ 1, 1, 240] when 0xf0000000 then [ 1, 1, 0] end else @scale_x, @scale_y, @angle = case tileid & 0xe0000000 when 0x20000000 then [ 1, -1, 90] when 0x40000000 then [ 1, -1, 0] when 0x60000000 then [-1, -1, 90] when 0x80000000 then [-1, 1, 0] when 0xa0000000 then [ 1, 1, 90] when 0xc0000000 then [-1, -1, 0] when 0xe0000000 then [-1, 1, 90] end end extend DXRuby::Tiled::DiagonallyFlippedTile if @angle == 90 end |
Instance Attribute Details
#angle ⇒ Object (readonly)
Returns the value of attribute angle.
59 60 61 |
# File 'lib/dxruby_tiled/tile.rb', line 59 def angle @angle end |
#scale_x ⇒ Object (readonly)
Returns the value of attribute scale_x.
59 60 61 |
# File 'lib/dxruby_tiled/tile.rb', line 59 def scale_x @scale_x end |
#scale_y ⇒ Object (readonly)
Returns the value of attribute scale_y.
59 60 61 |
# File 'lib/dxruby_tiled/tile.rb', line 59 def scale_y @scale_y end |
#tile ⇒ Object (readonly)
Returns the value of attribute tile.
59 60 61 |
# File 'lib/dxruby_tiled/tile.rb', line 59 def tile @tile end |
Instance Method Details
#adjusted_offset_y ⇒ Object
107 |
# File 'lib/dxruby_tiled/tile.rb', line 107 def adjusted_offset_y; @tile.adjusted_offset_y; end |
#collision ⇒ Object
111 |
# File 'lib/dxruby_tiled/tile.rb', line 111 def collision; @tile.collision; end |
#collision=(value) ⇒ Object
112 |
# File 'lib/dxruby_tiled/tile.rb', line 112 def collision=(value); @tile.collision = value; end |
#collision_enable ⇒ Object
113 |
# File 'lib/dxruby_tiled/tile.rb', line 113 def collision_enable; @tile.collision_enable; end |
#collision_enable=(value) ⇒ Object
114 |
# File 'lib/dxruby_tiled/tile.rb', line 114 def collision_enable=(value); @tile.collision_enable = value; end |
#height ⇒ Object
102 |
# File 'lib/dxruby_tiled/tile.rb', line 102 def height; @tile.height; end |
#image ⇒ Object
103 |
# File 'lib/dxruby_tiled/tile.rb', line 103 def image; @tile.image; end |
#offset_x ⇒ Object
105 |
# File 'lib/dxruby_tiled/tile.rb', line 105 def offset_x; @tile.offset_x; end |
#offset_y ⇒ Object
106 |
# File 'lib/dxruby_tiled/tile.rb', line 106 def offset_y; @tile.offset_y; end |
#original_image ⇒ Object
104 |
# File 'lib/dxruby_tiled/tile.rb', line 104 def original_image; @tile.original_image; end |
#render(x, y, target = DXRuby::Window, z_index = 0) ⇒ Object Also known as: draw
95 96 97 98 |
# File 'lib/dxruby_tiled/tile.rb', line 95 def render(x, y, target=DXRuby::Window, z_index = 0) target.draw_ex(x + offset_x, y + adjusted_offset_y, @tile.image, { scale_x: @scale_x, scale_y: @scale_y, angle: @angle, z: z_index }) end |
#tileset ⇒ Object
108 |
# File 'lib/dxruby_tiled/tile.rb', line 108 def tileset; @tile.tileset; end |
#to_sprite(x, y) ⇒ Object
116 117 118 |
# File 'lib/dxruby_tiled/tile.rb', line 116 def to_sprite(x, y) TileObject.new(x, y, self, rotation: @angle) end |
#type ⇒ Object
109 |
# File 'lib/dxruby_tiled/tile.rb', line 109 def type; @tile.type; end |
#type=(value) ⇒ Object
110 |
# File 'lib/dxruby_tiled/tile.rb', line 110 def type=(value); @tile.type = value; end |
#width ⇒ Object
101 |
# File 'lib/dxruby_tiled/tile.rb', line 101 def width; @tile.width; end |