Module: Shoes::DSL::Animate
- Included in:
- Shoes::DSL
- Defined in:
- shoes-core/lib/shoes/dsl/animate.rb
Instance Method Summary collapse
-
#animate(framerate = 24, opts = {}, &blk) ⇒ Shoes::Animation
Creates an animation that runs the given block of code.
-
#every(n = 1, opts = {}, &blk) ⇒ Shoes::Animation
Runs the associated block every N seconds.
-
#timer(n = 1, opts = {}, &blk) ⇒ Shoes::Timer
Runs the associated block every N seconds.
Instance Method Details
#animate(framerate = 24, opts = {}, &blk) ⇒ Shoes::Animation
Creates an animation that runs the given block of code. Defaults to framerate of 24 frames per second
21 22 23 24 |
# File 'shoes-core/lib/shoes/dsl/animate.rb', line 21 def animate(opts = {}, &blk) opts = { framerate: opts } unless opts.is_a? Hash Shoes::Animation.new @__app__, opts, blk end |
#every(n = 1, opts = {}, &blk) ⇒ Shoes::Animation
Runs the associated block every N seconds
32 33 34 |
# File 'shoes-core/lib/shoes/dsl/animate.rb', line 32 def every(n = 1, &blk) animate 1.0 / n, &blk end |
#timer(n = 1, opts = {}, &blk) ⇒ Shoes::Timer
Runs the associated block every N seconds
42 43 44 45 |
# File 'shoes-core/lib/shoes/dsl/animate.rb', line 42 def timer(n = 1, &blk) n *= 1000 Timer.new @__app__, n, &blk end |