Class: DXRuby::Tiled::TileObject
- Defined in:
- lib/dxruby_tiled/object.rb
Instance Attribute Summary collapse
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#tile ⇒ Object
Returns the value of attribute tile.
Attributes inherited from TMEObject
#id, #name, #properties, #type
Class Method Summary collapse
Instance Method Summary collapse
- #become(new_class) ⇒ Object
- #draw ⇒ Object
-
#initialize(x, y, tile, options = {}) ⇒ TileObject
constructor
A new instance of TileObject.
Constructor Details
#initialize(x, y, tile, options = {}) ⇒ TileObject
Returns a new instance of TileObject.
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/dxruby_tiled/object.rb', line 190 def initialize(x, y, tile, = {}) super x, y, @tile = tile self.image = tile.original_image if tile.is_a? FlippedTile self.scale_x = tile.scale_x self.scale_y = tile.scale_y @tile = tile.tile self.extend(FlippedTileObject) end self.angle = [:rotation] self.center_x = -tile.offset_x self.center_y = self.image.height - tile.offset_y self.collision = tile.collision self.collision_enable = tile.collision_enable self.offset_sync = true @start_time = nil end |
Instance Attribute Details
#start_time ⇒ Object
Returns the value of attribute start_time.
174 175 176 |
# File 'lib/dxruby_tiled/object.rb', line 174 def start_time @start_time end |
#tile ⇒ Object
Returns the value of attribute tile.
173 174 175 |
# File 'lib/dxruby_tiled/object.rb', line 173 def tile @tile end |
Class Method Details
.create_from_hash(hash) ⇒ Object
186 187 188 |
# File 'lib/dxruby_tiled/object.rb', line 186 def self.create_from_hash(hash) self.new(hash[:x], hash[:y], hash[:tile], hash) end |
.evolve(object) ⇒ Object
176 177 178 179 180 181 182 183 184 |
# File 'lib/dxruby_tiled/object.rb', line 176 def self.evolve(object) new_object = self.new(object.x, object.y, object.tile, id: @id) %w[z angle scale_x scale_y center_x center_y alpha blend shader image target collision collision_enable collision_sync visible offset_sync name type start_time].each do |arg| new_object.send(arg + "=", object.send(arg)) end end |
Instance Method Details
#become(new_class) ⇒ Object
223 224 225 |
# File 'lib/dxruby_tiled/object.rb', line 223 def become(new_class) new_class.evolve(self) end |
#draw ⇒ Object
209 210 211 212 213 214 215 216 |
# File 'lib/dxruby_tiled/object.rb', line 209 def draw @start_time ||= DXRuby::Window::running_time tile = @tile.animate((DXRuby::Window::running_time - @start_time)) self.image = tile.original_image self.center_x = -tile.offset_x self.center_y = self.image.height - tile.offset_y super end |