Class: DXRuby::Tiled::TextObject
- Defined in:
- lib/dxruby_tiled/object.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
Attributes inherited from TMEObject
#id, #name, #properties, #type
Class Method Summary collapse
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(x, y, width, height, text, options = {}) ⇒ TextObject
constructor
A new instance of TextObject.
Constructor Details
#initialize(x, y, width, height, text, options = {}) ⇒ TextObject
Returns a new instance of TextObject.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/dxruby_tiled/object.rb', line 142 def initialize(x, y, width, height, text, = {}) [:width] = width [:height] = height super x, y, @text = text @fontfamily = [:fontfamily] || "" @pixelsize = [:pixelsize] || 16 @wrap = !![:wrap] # unsupported @color = ([:color] || "000000").sub("#", "").scan(/../).map{ |c| c.to_i(16) } @bold = !![:bold] @italic = !![:italic] @underline = !![:underline] # unsupported @strikeout = !![:strikeout] # unsupported @kerning = [:kerning] != false # unsupported @halign = [:halign] || "left" # unsupported @valign = [:valign] || "top" # unsupported @font = DXRuby::Font.new(@pixelsize, @fontfamily, weight: @bold, italic: @italic, auto_fitting: true ) self.collision = [0, 0, @width, @height] end |
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
136 137 138 |
# File 'lib/dxruby_tiled/object.rb', line 136 def text @text end |
Class Method Details
.create_from_hash(hash) ⇒ Object
138 139 140 |
# File 'lib/dxruby_tiled/object.rb', line 138 def self.create_from_hash(hash) self.new(hash[:x], hash[:y], hash[:width], hash[:height], hash[:text][:text], hash[:text]) end |
Instance Method Details
#draw ⇒ Object
165 166 167 168 169 |
# File 'lib/dxruby_tiled/object.rb', line 165 def draw self.target.draw_font(self.x, self.y, @text, @font, color: @color, center_x: 0, center_y: 0, angle: self.angle, z: self.z ) end |