Source code for and a basic demonstration of generating animations based on
png or jpg sprite sheet files.
image explosion = spritesheet_animation("images/explosion.png", 8, 6)|
Important
|
Requires Ren’Py 8.3+ |
Generates an animation from the given sprite file path. The given path MUST be
a valid path relative to the game directory including the file extension, e.g.
"images/explosion.png".
This method supports the following file types: [ "png", "jpg" ]
|
|
The path to the sprite sheet image file relative to the game directory. This
path MUST include the file extension. Example: |
|
|
Number of sprites the sprite sheet has along the x-axis. |
|
|
Number of sprites the sprite sheet has along the y-axis. |
|
|
Frames per second for the animation. Incompatible with the |
|
|
How long to pause between each frame. Incompatible with the |
|
|
Whether the animation should loop. Defaults to |
|
|
Whether the animation should hold on the last frame or "vanish" after the last
frame has played. Defaults to |
-
This function does not allow the creation of animations with different pause times between frames. For example replicating the following is not possible:
image foobar: "frame01" pause 0.1 "frame02" pause 0.2 "frame03" pause 0.3
-
All the sprites on the sprite sheet must be the same size, the function will divide the sprite sheet evenly by the given
x_sprite_countandy_sprite_countvalues.
-
__get_image_sizeadapted from an answer on this StackOverflow question. -
explosion.pngfrom https://www.pngegg.com/en/png-nvowz
Published under the MIT License which practically says "go nuts, use it however you want."