AnimatedSprite

Pixel~ AnimatedSprite

AnimatedSprite Class.

Constructor

new AnimatedSprite(config, sheet, speedopt)

Source:
Create new Animated Sprite Object.
Parameters:
Name Type Attributes Default Description
config object | false The configuration object, only passed if it is a json file.
sheet Pixel.SpriteSheet#sheet | Pixel.SpriteSheet#generateSheet The Sprite Sheet.
speed number <optional>
0.15 Speed of animation.

Extends

Members

anchor :Pixel.Point

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

animation :Pixel.EXPORTS.AnimationCore

Source:
Animation Core for playing the animations.
Type:

config :object

Source:
JSON Config file.
Type:
  • object

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:

render

Source:
Renders current animation frame of sprite.

scale :number

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

speed :number

Source:
Default Value:
  • 0.15
Speed of the animation.
Type:
  • number

texture :object|Pixel.SpriteSheet#sheet|Pixel.SpriteSheet#generateSheet

Source:
SpriteSheet's image.
Type:

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.

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.