class Core::Animation
Attributes
x[RW]
y[RW]
Public Class Methods
new(graphic, sx, sy, repeat, frames)
click to toggle source
# 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
Public Instance Methods
draw()
click to toggle source
# 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()
click to toggle source
# File lib/animation.rb, line 28 def frame return @frames[@index] end
play(x, y, z)
click to toggle source
# File lib/animation.rb, line 32 def play(x, y, z) @x, @y, @z = x, y, z end
remove?()
click to toggle source
# File lib/animation.rb, line 46 def remove? return @remove end
Private Instance Methods
next_frame()
click to toggle source
# File lib/animation.rb, line 52 def next_frame @index += 1 if @index >= @frames.size if @repeat @index = 0 else @remove = true end end end