Skip to content
Francisco Cunha edited this page Jul 22, 2017 · 2 revisions

TextHelper

Grants a bunch of positioning utilities for your images. All functions of this mini extension return Vector2 objects.

To center a piece of text (in a given font) on the screen, you'd call:

TextHelper.center(font, text, WORLD_WIDTH, WORLD_HEIGHT)

You can also choose to center only horizontally or vertically:

TextHelper.centerX(font, text, WORLD_WIDTH, targetY)
TextHelper.centerY(font, text, WORLD_HEIGHT, targetX)

Or even inside an image:

TextHelper.centerOnImage(font, text, imageWidth, imageHeight, imagePosition)

img

Clone this wiki locally