Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/foxcapades/renpy-spritesheet-animation
Demonstration and source for generating animations from sprite sheets.
https://github.com/foxcapades/renpy-spritesheet-animation
animation renpy spritesheet
Last synced: 5 days ago
JSON representation
Demonstration and source for generating animations from sprite sheets.
- Host: GitHub
- URL: https://github.com/foxcapades/renpy-spritesheet-animation
- Owner: Foxcapades
- License: mit
- Created: 2023-07-06T04:01:45.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-11T05:03:24.000Z (26 days ago)
- Last Synced: 2024-10-17T01:19:20.014Z (20 days ago)
- Topics: animation, renpy, spritesheet
- Language: Ren'Py
- Homepage:
- Size: 3.25 MB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.adoc
- License: license
Awesome Lists containing this project
README
= Animations from Sprite Sheets
:source-highlighter: highlight.jsSource code for and a basic demonstration of generating animations based on
`png` or `jpg` sprite sheet files.[source, python]
----
image explosion = spritesheet_animation("images/explosion.png", 8, 6)
----[IMPORTANT]
--
Requires Ren'Py 8.3+
--== The `spritesheet_animation` Function
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" ]`
.Arguments
--
[cols="1m,1m,8"]
|===| image_path
| str
| The path to the sprite sheet image file relative to the game directory. This
path **MUST** include the file extension. Example: `"images/explosion.png"`.| x_sprite_count
| int
| Number of sprites the sprite sheet has along the x-axis.| y_sprite_count
| int
| Number of sprites the sprite sheet has along the y-axis.
|===
--.Keyword Arguments
--
[cols="1m,1m,8"]
|===| fps
| int\|float
| Frames per second for the animation. Incompatible with the `pause` keyword
argument; setting both will cause an error. Defaults to 30.| pause
| float
| How long to pause between each frame. Incompatible with the `fps` keyword
argument; setting both will cause an error. Defaults to None.| looping
| bool
| Whether the animation should loop. Defaults to `False`.| hold_last_frame
| bool
| Whether the animation should hold on the last frame or "vanish" after the last
frame has played. Defaults to `False` (vanishing).
|===
--== Caveats
. This function does not allow the creation of animations with different pause
times between frames. For example replicating the following is not possible:
+
[source, python]
----
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_count` and
`y_sprite_count` values.== Credits
* `__get_image_size` adapted from an answer on
link:https://stackoverflow.com/a/20380514[this StackOverflow question].
* `explosion.png` from https://www.pngegg.com/en/png-nvowz== License
Published under the link:license[MIT License] which practically says "go nuts,
use it however you want."