| 1 | # sprite_sheet_animation |
| 2 | |
| 3 | Simple demo using sprite sheets. |
| 4 | |
| 5 | This demo uses the most advised way to deal with sptite sheets: |
| 6 | |
| 7 | - create/modify them using CGE sprite sheet editor |
| 8 | |
| 9 | - save as a `.castle-sprite-sheet` file |
| 10 | |
| 11 | - load to TCastleScene. |
| 12 | |
| 13 | See [sprite sheets documentation](https://castle-engine.io/sprite_sheets). |
| 14 | |
| 15 | # Alternatives |
| 16 | |
| 17 | - You can use `TGLVideo2D` class to render a series of images, |
| 18 | like in the "data/hero_animation/single_frames_60fps/*.png" directory here. |
| 19 | Load a series of images using the `TVideo.Load` with URL |
| 20 | `data/hero_animation/single_frames_60fps/hawaii_exo-walking_@counter(1).png` . |
| 21 | Then create `TGLVideo2D` instance and render like |
| 22 | `MyVideo.DrawableImageFromTime(...).Draw(...)`. |
| 23 | |
| 24 | But this method is *not* advised. |
| 25 | Using the sprite sheet results in faster rendering, since it's a single image |
| 26 | for GPU. |
| 27 | |
| 28 | - You can design the 2D animation in Spine (or Dragon Bones) and export it to Spine JSON. |
| 29 | Or you can design it in Blender, and export to glTF. |
| 30 | |
| 31 | In either case, you get a smooth animation, using bones, |
| 32 | and can load it using TCastleScene.Load into Castle Game Engine. |
| 33 | |
| 34 | This is *the best approach for 2D animation*, |
| 35 | that results in a perfectly smooth animation, |
| 36 | without having a prerecorded number of images. |
| 37 | But it requires preparing an animation as a "real" 2D or 3D animation format, |
| 38 | not as a series of images. |
| 39 | |
| 40 | - CGE also exposes `TSprite` class that allows to manually load and render |
| 41 | sprite sheets. It is deprecated now. |