Class: Airsprite::SpriteFrame
- Inherits:
-
Object
- Object
- Airsprite::SpriteFrame
- Defined in:
- lib/airsprite/base.rb
Instance Attribute Summary collapse
-
#area ⇒ Object
Returns the value of attribute area.
-
#data ⇒ Object
Returns the value of attribute data.
-
#height ⇒ Object
Returns the value of attribute height.
-
#name ⇒ Object
Returns the value of attribute name.
-
#position ⇒ Object
Returns the value of attribute position.
-
#speed ⇒ Object
Returns the value of attribute speed.
-
#width ⇒ Object
Returns the value of attribute width.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
-
#initialize(name, path) ⇒ SpriteFrame
constructor
A new instance of SpriteFrame.
- #to_s ⇒ Object
- #to_short_s ⇒ Object
Constructor Details
#initialize(name, path) ⇒ SpriteFrame
Returns a new instance of SpriteFrame.
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/airsprite/base.rb', line 241 def initialize(name, path) split_name = name.split('-') if split_name.size == 1 @name = split_name[0] @speed = 0 else @name = split_name.shift @speed = split_name.join.to_i end @data = Magick::Image::read(path).first @width = @data.columns.to_i @height = @data.rows.to_i @area = @width * @height end |
Instance Attribute Details
#area ⇒ Object
Returns the value of attribute area.
239 240 241 |
# File 'lib/airsprite/base.rb', line 239 def area @area end |
#data ⇒ Object
Returns the value of attribute data.
238 239 240 |
# File 'lib/airsprite/base.rb', line 238 def data @data end |
#height ⇒ Object
Returns the value of attribute height.
239 240 241 |
# File 'lib/airsprite/base.rb', line 239 def height @height end |
#name ⇒ Object
Returns the value of attribute name.
238 239 240 |
# File 'lib/airsprite/base.rb', line 238 def name @name end |
#position ⇒ Object
Returns the value of attribute position.
238 239 240 |
# File 'lib/airsprite/base.rb', line 238 def position @position end |
#speed ⇒ Object
Returns the value of attribute speed.
238 239 240 |
# File 'lib/airsprite/base.rb', line 238 def speed @speed end |
#width ⇒ Object
Returns the value of attribute width.
239 240 241 |
# File 'lib/airsprite/base.rb', line 239 def width @width end |
#x ⇒ Object
Returns the value of attribute x.
239 240 241 |
# File 'lib/airsprite/base.rb', line 239 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
239 240 241 |
# File 'lib/airsprite/base.rb', line 239 def y @y end |
Instance Method Details
#to_s ⇒ Object
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/airsprite/base.rb', line 258 def to_s <<-EOS SpriteFrame { name "#{name}" speed #{speed} position #{position} width #{width} height #{height} area #{area} x #{x} y #{y} } EOS end |
#to_short_s ⇒ Object
274 275 276 |
# File 'lib/airsprite/base.rb', line 274 def to_short_s "frame: #{width} x #{height} = #{area} (#{x}, #{y})" end |