Class: TextSprite

TextSprite(text, x, y)

new TextSprite(text, x, y)

A sprite that is a string of text. It can change position, visibility, color, font, alignment, and the actual text. Also includes hitbox detection.
Parameters:
Name Type Description
text String The String that will be rendered
x Number The x position of this sprite
y Number The y position of this sprite
Properties:
Name Type Description
align String Which direction this text is aligned to. Acceptable values: "left", "start", "center", "right", "end". Default: "left"
text String The String that will be rendered
x Number The x position of this sprite
y Number The y position of this sprite
visible Boolean A boolean value of whether of not this sprite is visible/will be rendered. True means it will be rendered
color String The color of the text
font String The size and font of the text. Default value: "30px Arial"
Source:

Methods

(static) draw(game)

Renders the sprite onto the give game canvas.
Parameters:
Name Type Description
game Game The game this sprite will be rendered onto
Source:

(static) hide()

Makes this sprite not visible
Source:

(static) hide()

Makes this sprite visible
Source:

(static) inHit(cx, cy) → {Boolean}

Checks to see if the given coordinates are within the sprite's "hit box"
Parameters:
Name Type Description
cx Number The x coordinate
cy Number The y coordinate
Source:
Returns:
True is the coordinates are within the "hit box", False otherwise.
Type
Boolean