Class: Core::Animation
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #draw ⇒ Object
- #frame ⇒ Object
-
#initialize(graphic, sx, sy, repeat, frames) ⇒ Animation
constructor
A new instance of Animation.
- #play(x, y, z) ⇒ Object
- #remove? ⇒ Boolean
Constructor Details
#initialize(graphic, sx, sy, repeat, frames) ⇒ Animation
Returns a new instance of Animation.
18 19 20 21 22 23 24 25 26 |
# File 'lib/animation.rb', line 18 def initialize(graphic, sx, sy, repeat, frames) @anim_frames = Core.tiles("animations/#{graphic}", sx, sy, false) @repeat = repeat @frames = frames @index = 0 @time = 0 @x, @y = 0 @remove = false end |
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x.
17 18 19 |
# File 'lib/animation.rb', line 17 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
17 18 19 |
# File 'lib/animation.rb', line 17 def y @y end |
Instance Method Details
#draw ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/animation.rb', line 36 def draw return if remove? @anim_frames[@index].draw(@x + frame.x, @y + frame.y, @z, 1, 1, frame.color, frame.mode) @time += 1 if @time >= frame.length @time = 0 next_frame end end |
#frame ⇒ Object
28 29 30 |
# File 'lib/animation.rb', line 28 def frame return @frames[@index] end |
#play(x, y, z) ⇒ Object
32 33 34 |
# File 'lib/animation.rb', line 32 def play(x, y, z) @x, @y, @z = x, y, z end |
#remove? ⇒ Boolean
46 47 48 |
# File 'lib/animation.rb', line 46 def remove? return @remove end |