Class: MovieMaker::Action::SpriteAction

Inherits:
Object
  • Object
show all
Defined in:
lib/movie_maker/action.rb

Overview

All actions inherit from this base-class and Should call super in their initialize. Takes an option-hash: :start_at - start at X millisec into the movie :stop_at - stop at X millisec into the movie :sprite - the actuall spriteobject, needs to answer to x,x=,y,y= and image :screen - the screenobject, so it knows where to blit itself :background - the backgroundsurface so it can undraw itself properly

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, *ignore) ⇒ SpriteAction

Returns a new instance of SpriteAction.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/movie_maker/action.rb', line 21

def initialize(options = {}, *ignore)
  @sprite = options[:object]
  @background = options[:background]
  @screen = options[:screen]
  @start_at = (options[:start_at]||0) * 1000
  @stop_at = (options[:stop_at]||0) * 1000
  @cache = options[:cache] || false
  @framework = options[:framework] || :rubygame
  
  @duration = @stop_at - @start_at
  @playing = true
  @finalized = false
  @setup_done = false
  @image = @sprite.image # used in MovieMaker#play
end

Instance Attribute Details

#backgroundObject

Returns the value of attribute background.



19
20
21
# File 'lib/movie_maker/action.rb', line 19

def background
  @background
end

#imageObject (readonly)

Returns the value of attribute image.



20
21
22
# File 'lib/movie_maker/action.rb', line 20

def image
  @image
end

#screenObject

Returns the value of attribute screen.



19
20
21
# File 'lib/movie_maker/action.rb', line 19

def screen
  @screen
end

#spriteObject

Returns the value of attribute sprite.



19
20
21
# File 'lib/movie_maker/action.rb', line 19

def sprite
  @sprite
end

#start_atObject (readonly)

Returns the value of attribute start_at.



20
21
22
# File 'lib/movie_maker/action.rb', line 20

def start_at
  @start_at
end

#stop_atObject (readonly)

Returns the value of attribute stop_at.



20
21
22
# File 'lib/movie_maker/action.rb', line 20

def stop_at
  @stop_at
end

Instance Method Details

#finalizeObject



41
42
43
# File 'lib/movie_maker/action.rb', line 41

def finalize
  @finalized = true
end

#finalized?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/movie_maker/action.rb', line 45

def finalized?
  @finalized
end

#playing?(current_time) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/movie_maker/action.rb', line 53

def playing?(current_time)
  @playing and (current_time >= self.start_at) and (current_time < self.stop_at)
end

#setupObject



37
38
39
# File 'lib/movie_maker/action.rb', line 37

def setup
  @setup_done = true
end

#started?(current_time) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/movie_maker/action.rb', line 49

def started?(current_time)
  current_time >= self.start_at
end