Class: RedBird::Animation::Loop
Overview
This animation starts in the first frame and goes through every frame until the last, then it goes back to the first frame and starts again.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#animate ⇒ Object
This method must be called for every tick.
Methods inherited from Base
Constructor Details
This class inherits a constructor from RedBird::Animation::Base
Instance Method Details
#animate ⇒ Object
This method must be called for every tick. It changes the current displayed sprite.
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/red_bird/animation.rb', line 68 def animate @current_time += 1 if @current_time > @frames[@current_frame].duration then @current_time -= @frames[@current_frame].duration @current_frame += 1 if @current_frame >= @frames.size then @current_frame = 0 end @current_sprite = @frames[@current_frame].sprite end end |