Class: Shoes::Anim

Inherits:
Object show all
Defined in:
lib/shoes/anim.rb

Instance Method Summary collapse

Constructor Details

#initialize(cs, n = 100, repaint = true, &blk) ⇒ Anim

Returns a new instance of Anim.



3
4
5
# File 'lib/shoes/anim.rb', line 3

def initialize cs, n=100, repaint=true, &blk
  @cs, @n, @repaint, @i, @blk = cs, n, repaint, 0, blk
end

Instance Method Details

#continue?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/shoes/anim.rb', line 24

def continue?
  !@stop
end

#pauseObject



28
29
30
# File 'lib/shoes/anim.rb', line 28

def pause
  @pause = !@pause
end

#pause?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/shoes/anim.rb', line 32

def pause?
  @pause
end

#runObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/shoes/anim.rb', line 7

def run
  if continue? 
    @blk[@i = pause? ? @i : @i+1]
    if @cs.isDisposed
      stop
      return
    elsif @repaint
      @cs.redraw
    end
    Shoes.display.timerExec @n, self
  end
end

#stopObject



20
21
22
# File 'lib/shoes/anim.rb', line 20

def stop
  @stop = true
end