Text

Pixel~ Text

Text class.

Constructor

new Text(txt, size, copt)

Source:
Create new text object.
Parameters:
Name Type Attributes Default Description
txt string | number Text to be printed.
size number Size of the text.
c string <optional>
"#000000" Color of the text.

Extends

Members

anchor :Pixel.Point

Source:
Overrides:
The anchor position of the sprite.
Type:

color :string

Source:
The color of the text.
Type:
  • string

deg :number

Source:
Overrides:
Default Value:
  • 0
The degress of rotation on the sprite.
Type:
  • number

flipX :boolean

Source:
Overrides:
Default Value:
  • false
Determines if the sprite is flipped over the x axis.
Type:
  • boolean

flipY :boolean

Source:
Overrides:
Default Value:
  • false
Determines if the sprite is flipped over the y axis.
Type:
  • boolean

height :number

Source:
Overrides:
Height of the Sprite's hitbox.
Type:
  • number

id :string

Source:
Overrides:
Default Value:
  • 0
The id of the sprite, used to find sprites when deleting them.
Type:
  • string

opacity :number

Source:
Overrides:
The opacity of the sprite.
Type:
  • number

point :Pixel.Point

Source:
Overrides:
The position of the sprite.
Type:

scale :number

Source:
Overrides:
Default Value:
  • 1
The scale of the sprite (0 --> 1).
Type:
  • number

size :number

Source:
The size of the text.
Type:
  • number

text :string

Source:
The text that will be printed.
Type:
  • string

width :number

Source:
Overrides:
Width of the Sprite's hitbox.
Type:
  • number

x :number

Source:
Overrides:
X position.
Type:
  • number

y :number

Source:
Overrides:
Y position.
Type:
  • number

Methods

copy(sprite)

Source:
Overrides:
Copy the value of another sprite onto this one.
Parameters:
Name Type Description
sprite Pixel.Sprite Sprite who's values this will copy.

render(ctx)

Source:
Renders text.
Parameters:
Name Type Description
ctx CanvasRenderingContext2d The Canvas to print to.

reset(ctx)

Source:
Overrides:
Resets settings set on sprite.
Parameters:
Name Type Description
ctx CanvasRenderingContext2d Context to reset settings on.

setAnchor(x, y)

Source:
Overrides:
Set the position the sprite is anchored to (0-->1).
Parameters:
Name Type Description
x number X position, scale of 0 to 1.
y number Y position, scale of 0 to 1.

setSize(w, h)

Source:
Overrides:
Sets the hitbox size of the sprite.
Parameters:
Name Type Description
w number Width.
h number Height.

settings(ctx)

Source:
Overrides:
Applies settings set on sprite.
Parameters:
Name Type Description
ctx CanvasRenderingContext2d Context to apply settings to.

spin(num)

Source:
Overrides:
Spins x * 360 degrees.
Parameters:
Name Type Description
num number Amount of times sprite rotates 360 degrees.