Sha256: 81b00b90888516e7a906b155e57eb7529674c709c46fc833ff83181086018fb8

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

class Shoes
  class Animation

    # Creates a new Animation.
    #
    # @overload initialize(opts, &blk)
    #   @param [Hash] opts An options hash
    #   @param [Proc] blk A block of code to be executed for each
    #     animation frame
    #   @option opts [Integer] :framerate (24) The framerate (frames per second)
    #   @option opts [Shoes::App] :app The current Shoes app
    def initialize(app, opts, blk)
      @style = opts
      @framerate = @style[:framerate] || 10
      @app = app
      @blk = blk
      @current_frame = 0
      @stopped = false
      @gui = Shoes.configuration.backend_for(self, @app.gui)
    end

    attr_reader :current_frame, :framerate, :blk

    def start
      @stopped = false
    end

    def stop
      @stopped = true
    end

    def stopped?
      @stopped
    end

    def toggle
     @stopped = !@stopped
    end

    def remove
      @removed = true
    end

    def removed?
      @removed
    end

    # Increments the current frame by 1
    #
    # @return [Integer] The new current frame
    def increment_frame
      @current_frame += 1
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoes-4.0.0.pre1 lib/shoes/animation.rb