class Scar::Components::Text

Overview

This component is a wrapper around SF::Text

Example usage:

Assets.default_font = Assets.font "fonts/arial.ttf"
title_text = Scar::Components::Text.new("Game Title")
title = Scar::Entity.new("title", title_text)
title.position = Vec.new(100, 100)

Defined in:

scar/components/text.cr

Constructors

Instance Method Summary

Instance methods inherited from module Scar::Drawable

blend_mode : SF::BlendMode blend_mode, blend_mode=(blend_mode : SF::BlendMode) blend_mode=, drawable : SF::Drawable drawable, shader : SF::Shader shader, shader=(shader : SF::Shader) shader=, texture : SF::Texture texture, texture=(texture : SF::Texture) texture=, visible=(visible) visible=, visible? visible?

Constructor Detail

def self.new(text : String, font : SF::Font | Nil = nil) #

Creates a new text component with the given String content and font

If no font is given, the component will try to use Assets#default_font. This only works if Assets#default_font is set.


[View source]

Instance Method Detail

def drawable : SF::Text #

Returns the underlying SF::Text


[View source]
def font : SF::Font? #

Returns the SF::Font this component uses


[View source]
def font=(new_font : SF::Font) #

Sets the font this component should use


[View source]
def text : String #

Returns the String contents of this component


[View source]
def text=(new_text : String) #

Replaces the components' String content with the provided new one


[View source]