Class: RedBird::Animation::Loop

Inherits:
Base
  • Object
show all
Defined in:
lib/red_bird/animation.rb

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

#current_sprite

Instance Method Summary collapse

Methods inherited from Base

#initialize, #reset

Constructor Details

This class inherits a constructor from RedBird::Animation::Base

Instance Method Details

#animateObject

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