The namespace containing functions to load and manage sprite assets
- Source:
Methods
(static) add(scene, sprite, x, y, pivot_x, pivot_y)
Add and position a new sprite into the scene.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
scene |
object
|
The scene object where to add the image. |
sprite |
object
|
The object of a sprite as returned by PP.assets.sprite.load |
x |
number
|
The horizontal initial position in pixels of the image. |
y |
number
|
The vertical initial position in pixels of the image. |
pivot_x |
number
|
The pivot X position **in percentage** from 0 to 1. |
pivot_y |
number
|
The pivot Y position **in percentage** from 0 to 1. |
Returns:
An sprite instance object representing the specific sprite added to the scene.
(static) animation_add(sprite_instance, animation_name, frame_start_nr, frame_end_nr, frame_rate, repeat)
Add a new animation to a given sprite.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
sprite_instance |
object
|
The object of a sprite instance as returned by PP.assets.sprite.add |
animation_name |
string
|
A unique name (in the current sprite instance) for this animation. |
frame_start_nr |
number
|
The starting frame number (counting from top-left, horizontal first) of the spritesheet. |
frame_end_nr |
number
|
The ending frame number (counting from top-left, horizontal first) of the spritesheet. |
frame_rate |
number
|
The frame rate of the spritesheet in FPS. |
repeat |
number
|
The number of time the animation should repeat. Use -1 for infinite. |
(static) animation_add_list(sprite_instance, animation_name, frame_list, frame_rate, repeat)
Add a new animation to a given sprite using a custom list of frame numbers.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
sprite_instance |
object
|
The object of a sprite instance as returned by PP.assets.sprite.add |
animation_name |
string
|
A unique name (in the current sprite instance) for this animation. |
frame_list |
array
|
The list of frames. |
frame_rate |
number
|
The frame rate of the spritesheet in FPS. |
repeat |
number
|
The number of time the animation should repeat. Use -1 for infinite. |
(static) animation_play(sprite_instance, animation_name)
Play the requested animation of the sprite instance passed as parameter. The animation must have been
previously added via PP.assets.sprite.animation_add
- Source:
Parameters:
Name | Type | Description |
---|---|---|
sprite_instance |
object
|
The object of the sprite instance returned by PP.assets.sprite.add. |
animation_name |
string
|
The name of the animation. |
(static) animation_stop(sprite_instance)
Stop the current animation of the sprite instance passed as parameter
- Source:
Parameters:
Name | Type | Description |
---|---|---|
sprite_instance |
object
|
The object of the sprite instance returned by PP.assets.sprite.add. |
(static) load_spritesheet(scene, image_path, frame_width, frame_height)
Load a new spritesheet.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
scene |
object
|
The scene object. |
image_path |
string
|
A path of the image containing the spritesheet to load. It can be relative to the current page or a full URL. |
frame_width |
number
|
The frame width of the spritesheet in px. |
frame_height |
number
|
The frame height of the spritesheet in px. |
Returns:
An object representing the spritesheet image file.