1. Computing & Technology

Discuss in my forum

Click Blocks and Animation

By , About.com Guide

Getting Animated
Click Blocks and Animation

The animate method will run a block at a set interval. Its single parameter defines the interval at which this method will be called in frames per second. In this example, an animate block at one frame per second will increment a counter and display the result.

More sophisticated uses of animate can include creating actual animation with multiple image objects, implementing flashing text, or doing anything else that requires a timed interval.

Shoes.app :width => 400, :height => 300 do
  @box = stack
  @num = 0

  animate(1) do
    @num += 1
    @box.append para("#{@num}\n")
  end
end

©2012 About.com. All rights reserved.

A part of The New York Times Company.