summaryrefslogtreecommitdiffhomepage
path: root/lib/ruby2d/camera/text.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ruby2d/camera/text.rb')
-rw-r--r--lib/ruby2d/camera/text.rb27
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/ruby2d/camera/text.rb b/lib/ruby2d/camera/text.rb
index 21c9e1b..6966a86 100644
--- a/lib/ruby2d/camera/text.rb
+++ b/lib/ruby2d/camera/text.rb
@@ -10,11 +10,10 @@ module Ruby2D
# to be corrected again(see image_wrapper.rb for reference, that has
# math that allows for resizing)
class Text < Ruby2D::Text
- @center = false
-
# Recalculates real coordiantes
# Use after changing variables
def _draw
+ return if @hide
angle = Camera.angle * (Math::PI / 180)
half_width = Window.width * 0.5
half_height = Window.height * 0.5
@@ -31,18 +30,34 @@ module Ruby2D
* Camera.zoom + half_height - (height / 2)
temp_rotate = rotate + Camera.angle
# Workaround for resizing text
+ # TODO: resizing doesnt work at all even with workaround
temp_size = size# * Camera.zoom
self.size *= Camera.zoom
self.draw(x: temp_x, y: temp_y,
rotate: temp_rotate,
- color: self.color)
+ color: [self.color.r, self.color.g, self.color.b, self.color.a])
self.size = temp_size
end
- def initialize(opts = {})
- super(opts)
+ def initialize(text, opts= {})
+ super(text, opts)
Ruby2D::Camera << self
- self.remove
+ Window.remove(self)
+ end
+ def remove
+ @hide = true
+ end
+
+ def add
+ @hide = false
+ end
+
+ def center
+ @center
+ end
+
+ def center=(center)
+ @center = center
end
end
end