Class: RedBird::Animation::Frame
- Inherits:
-
Object
- Object
- RedBird::Animation::Frame
- Defined in:
- lib/red_bird/animation.rb
Overview
Each frame has a sprite and a duration.
Instance Attribute Summary collapse
-
#duration ⇒ Integer
readonly
How long this frame lasts.
-
#sprite ⇒ RedBird::Sprite
readonly
Sprite to display in this frame.
Class Method Summary collapse
-
.sequence(frames) ⇒ Object
Create an array of frames and return it.
Instance Method Summary collapse
-
#initialize(duration, sprite) ⇒ Frame
constructor
A new instance of Frame.
Constructor Details
#initialize(duration, sprite) ⇒ Frame
Returns a new instance of Frame.
20 21 22 23 |
# File 'lib/red_bird/animation.rb', line 20 def initialize(duration, sprite) @duration = duration @sprite = sprite end |
Instance Attribute Details
#duration ⇒ Integer (readonly)
Returns how long this frame lasts.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/red_bird/animation.rb', line 13 class Frame attr_reader :duration, :sprite # @param duration [Integer] this animation frame will persist for as many # game frames as defined by this value. # @param sprite [RedBird::Sprite] sprite to be displayed in this frame. # @author Frederico Linhares def initialize(duration, sprite) @duration = duration @sprite = sprite end # Create an array of frames and return it. This method must receive an # Array. # # @param frames [Array] each object in it must be an array containing the # attributes for each frame returned. # @author Frederico Linhares def self.sequence(frames) return frames.collect { |i| Frame.new(i[0], i[1]) } end end |
#sprite ⇒ RedBird::Sprite (readonly)
Returns sprite to display in this frame.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/red_bird/animation.rb', line 13 class Frame attr_reader :duration, :sprite # @param duration [Integer] this animation frame will persist for as many # game frames as defined by this value. # @param sprite [RedBird::Sprite] sprite to be displayed in this frame. # @author Frederico Linhares def initialize(duration, sprite) @duration = duration @sprite = sprite end # Create an array of frames and return it. This method must receive an # Array. # # @param frames [Array] each object in it must be an array containing the # attributes for each frame returned. # @author Frederico Linhares def self.sequence(frames) return frames.collect { |i| Frame.new(i[0], i[1]) } end end |