Class: MovieMaker::Rubygame::Sprite
- Inherits:
-
Object
- Object
- MovieMaker::Rubygame::Sprite
- Includes:
- Rubygame::Sprites::Sprite
- Defined in:
- lib/movie_maker/sprite.rb
Overview
A basic spriteclass using rubygames Sprites::Sprite Autoloads a surface and initializes @rect
Instance Attribute Summary collapse
-
#angle ⇒ Object
Returns the value of attribute angle.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#height_scaling ⇒ Object
Returns the value of attribute height_scaling.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#rect ⇒ Object
Returns the value of attribute rect.
-
#width_scaling ⇒ Object
Returns the value of attribute width_scaling.
Instance Method Summary collapse
-
#initialize(file, x = 0, y = 0) ⇒ Sprite
constructor
A new instance of Sprite.
- #realign_center ⇒ Object
- #x ⇒ Object
-
#x=(value) ⇒ Object
Rubygame X/Y setters/getters.
- #y ⇒ Object
- #y=(value) ⇒ Object
Constructor Details
#initialize(file, x = 0, y = 0) ⇒ Sprite
Returns a new instance of Sprite.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/movie_maker/sprite.rb', line 13 def initialize(file, x=0, y=0) super() @file = file @image = Surface.autoload(file) @rect = Rect.new(x,y,*@image.size) @image.set_colorkey(@image.get_at(0,0)) @angle = 0.0 @width_scaling = 1.0 @height_scaling = 1.0 end |
Instance Attribute Details
#angle ⇒ Object
Returns the value of attribute angle.
12 13 14 |
# File 'lib/movie_maker/sprite.rb', line 12 def angle @angle end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
11 12 13 |
# File 'lib/movie_maker/sprite.rb', line 11 def file @file end |
#height_scaling ⇒ Object
Returns the value of attribute height_scaling.
12 13 14 |
# File 'lib/movie_maker/sprite.rb', line 12 def height_scaling @height_scaling end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
11 12 13 |
# File 'lib/movie_maker/sprite.rb', line 11 def image @image end |
#rect ⇒ Object
Returns the value of attribute rect.
12 13 14 |
# File 'lib/movie_maker/sprite.rb', line 12 def rect @rect end |
#width_scaling ⇒ Object
Returns the value of attribute width_scaling.
12 13 14 |
# File 'lib/movie_maker/sprite.rb', line 12 def width_scaling @width_scaling end |
Instance Method Details
#realign_center ⇒ Object
32 33 34 35 36 |
# File 'lib/movie_maker/sprite.rb', line 32 def realign_center old_center = @rect.center @rect.size = @image.size @rect.center = old_center end |
#x ⇒ Object
28 |
# File 'lib/movie_maker/sprite.rb', line 28 def x; @rect.centerx; end |
#x=(value) ⇒ Object
Rubygame X/Y setters/getters
27 |
# File 'lib/movie_maker/sprite.rb', line 27 def x=(value); @rect.centerx = value; end |
#y ⇒ Object
30 |
# File 'lib/movie_maker/sprite.rb', line 30 def y; @rect.centery; end |
#y=(value) ⇒ Object
29 |
# File 'lib/movie_maker/sprite.rb', line 29 def y=(value); @rect.centery = value; end |