Class: AuthorEngine::Text

Inherits:
Object
  • Object
show all
Includes:
Support
Defined in:
lib/author_engine/text.rb

Constant Summary collapse

FONT_DEFAULT =
"#{File.expand_path("../../../", __FILE__)}/assets/fonts/Connection.otf"
FONT_DEFAULT_BOLD =
"#{File.expand_path("../../../", __FILE__)}/assets/fonts/ConnectionBold.otf"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Support

#code_editor, #mouse_over?, #sprite_editor, #window

Constructor Details

#initialize(message: "", size: nil, x: 0, y: 0, z: 0, color: Gosu::Color::WHITE, font: FONT_DEFAULT) ⇒ Text

Consolas



9
10
11
12
13
14
15
16
# File 'lib/author_engine/text.rb', line 9

def initialize(message: "", size: nil, x: 0, y: 0, z: 0, color: Gosu::Color::WHITE, font: FONT_DEFAULT) # Consolas
  @message = message
  @size = size ? size : (8 * window.scale_y).floor
  @x, @y, @z = x, y, z
  @color, @font_name = color, font

  @font = Gosu::Font.new(@size, name: @font_name)
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



7
8
9
# File 'lib/author_engine/text.rb', line 7

def color
  @color
end

#fontObject (readonly)

Returns the value of attribute font.



8
9
10
# File 'lib/author_engine/text.rb', line 8

def font
  @font
end

#messageObject

Returns the value of attribute message.



7
8
9
# File 'lib/author_engine/text.rb', line 7

def message
  @message
end

#sizeObject (readonly)

Returns the value of attribute size.



8
9
10
# File 'lib/author_engine/text.rb', line 8

def size
  @size
end

#xObject

Returns the value of attribute x.



7
8
9
# File 'lib/author_engine/text.rb', line 7

def x
  @x
end

#yObject

Returns the value of attribute y.



7
8
9
# File 'lib/author_engine/text.rb', line 7

def y
  @y
end

#zObject

Returns the value of attribute z.



7
8
9
# File 'lib/author_engine/text.rb', line 7

def z
  @z
end

Instance Method Details

#drawObject



30
31
32
# File 'lib/author_engine/text.rb', line 30

def draw
  @font.draw_text(@message, @x, @y, @z, 1, 1, @color)
end

#draw_markupObject



34
35
36
# File 'lib/author_engine/text.rb', line 34

def draw_markup
  @font.draw_markup(@message, @x, @y, @z, 1, 1, @color)
end

#heightObject



26
27
28
# File 'lib/author_engine/text.rb', line 26

def height
  @font.height
end

#updateObject



38
39
# File 'lib/author_engine/text.rb', line 38

def update
end

#widthObject



18
19
20
# File 'lib/author_engine/text.rb', line 18

def width
  @font.text_width(@message)
end

#width_markupObject



22
23
24
# File 'lib/author_engine/text.rb', line 22

def width_markup
  @font.markup_width(@message)
end