Class: MovieMaker::Rubygame::TTFSprite
- Inherits:
-
Object
- Object
- MovieMaker::Rubygame::TTFSprite
- Includes:
- Rubygame::Sprites::Sprite
- Defined in:
- lib/movie_maker/sprite.rb
Overview
TTRSprite creates a rubygame sprite from a string/font Use this if you wanna move,rotate and zoom texts/letters
Instance Attribute Summary collapse
-
#angle ⇒ Object
Returns the value of attribute angle.
-
#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(string, options = {}) ⇒ TTFSprite
constructor
A new instance of TTFSprite.
- #realign_center ⇒ Object
- #x ⇒ Object
-
#x=(value) ⇒ Object
Rubygame X/Y setters/getters.
- #y ⇒ Object
- #y=(value) ⇒ Object
Constructor Details
#initialize(string, options = {}) ⇒ TTFSprite
Returns a new instance of TTFSprite.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/movie_maker/sprite.rb', line 49 def initialize(string, ={}) super() @string = string @color = [:color] || Color[:black] @size = [:size] || 15 @position = [:position] || [0,0] @fontname = [:fontname] || "FreeSans.ttf" @font = [:font] || nil if @font.nil? @font = TTF.new(File.join("fonts", @fontname), @size) end @rect = Rect.new(@position[0], @position[1], *@font.size_text(string)) @image = Surface.new(@rect.size, 0, [SRCCOLORKEY]) @font.render(@string, true, @color).blit(@image,[0,0]) @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.
48 49 50 |
# File 'lib/movie_maker/sprite.rb', line 48 def angle @angle end |
#height_scaling ⇒ Object
Returns the value of attribute height_scaling.
48 49 50 |
# File 'lib/movie_maker/sprite.rb', line 48 def height_scaling @height_scaling end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
47 48 49 |
# File 'lib/movie_maker/sprite.rb', line 47 def image @image end |
#rect ⇒ Object
Returns the value of attribute rect.
48 49 50 |
# File 'lib/movie_maker/sprite.rb', line 48 def rect @rect end |
#width_scaling ⇒ Object
Returns the value of attribute width_scaling.
48 49 50 |
# File 'lib/movie_maker/sprite.rb', line 48 def width_scaling @width_scaling end |
Instance Method Details
#realign_center ⇒ Object
80 81 82 83 84 |
# File 'lib/movie_maker/sprite.rb', line 80 def realign_center old_center = @rect.center @rect.size = @image.size @rect.center = old_center end |
#x ⇒ Object
76 |
# File 'lib/movie_maker/sprite.rb', line 76 def x; @rect.centerx; end |
#x=(value) ⇒ Object
Rubygame X/Y setters/getters
75 |
# File 'lib/movie_maker/sprite.rb', line 75 def x=(value); @rect.centerx = value; end |
#y ⇒ Object
78 |
# File 'lib/movie_maker/sprite.rb', line 78 def y; @rect.centery; end |
#y=(value) ⇒ Object
77 |
# File 'lib/movie_maker/sprite.rb', line 77 def y=(value); @rect.centery = value; end |