SpriteBase

Pixel.EXPORTS~ SpriteBase

The base of every Sprite.

Constructor

new SpriteBase(noscaleopt)

Source:
Create new Sprite Base.
Parameters:
Name Type Attributes Default Description
noscale boolean <optional>
false Determines whether or not object can be rotated and scaled.

Members

anchor :Pixel.Point

Source:
The anchor position of the sprite.
Type:

deg :number

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

flipX :boolean

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

flipY :boolean

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

height :number

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

id :string

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

opacity :number

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

point :Pixel.Point

Source:
The position of the sprite.
Type:

scale :number

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

width :number

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

x :number

Source:
X position.
Type:
  • number

y :number

Source:
Y position.
Type:
  • number

Methods

copy(sprite)

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

reset(ctx)

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

setAnchor(x, y)

Source:
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:
Sets the hitbox size of the sprite.
Parameters:
Name Type Description
w number Width.
h number Height.

settings(ctx)

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

spin(num)

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