Class: MovieMaker::Action::Zoom
- Inherits:
-
SpriteAction
- Object
- SpriteAction
- MovieMaker::Action::Zoom
- Defined in:
- lib/movie_maker/action.rb
Overview
Zoom a sprite
Instance Attribute Summary
Attributes inherited from SpriteAction
#background, #image, #screen, #sprite, #start_at, #stop_at
Instance Method Summary collapse
- #finalize ⇒ Object
-
#initialize(options = {}, factor = 1) ⇒ Zoom
constructor
A new instance of Zoom.
- #setup ⇒ Object
- #update(time) ⇒ Object
Methods inherited from SpriteAction
#finalized?, #playing?, #started?
Constructor Details
#initialize(options = {}, factor = 1) ⇒ Zoom
Returns a new instance of Zoom.
164 165 166 167 |
# File 'lib/movie_maker/action.rb', line 164 def initialize( = {}, factor = 1) super() @factor = factor end |
Instance Method Details
#finalize ⇒ Object
188 189 190 191 192 |
# File 'lib/movie_maker/action.rb', line 188 def finalize @sprite.width_scaling = @factor @sprite.height_scaling = @factor @finalized = true end |
#setup ⇒ Object
169 170 171 172 173 174 175 176 177 |
# File 'lib/movie_maker/action.rb', line 169 def setup @scale_from = @sprite.width_scaling || 1 @scale = (@scale_from - @factor).abs @scale_step = @scale.to_f / @duration.to_f @scale_step = -@scale_step if @factor < @scale_from @setup_done = true end |
#update(time) ⇒ Object
179 180 181 182 183 184 185 186 |
# File 'lib/movie_maker/action.rb', line 179 def update(time) setup unless @setup_done scale = @scale_from + @scale_step * time #puts "#{scale} = #{@scale_from} + #{@scale_step} * #{time}" @sprite.width_scaling = scale @sprite.height_scaling = scale end |