|
CorsixTH engine (the C++ part)
Open source implementation of Theme Hospital
|
Theme Hospital sprite animation manager. More...
#include <th_gfx.h>
Theme Hospital sprite animation manager.
An animation manager takes a sprite sheet and four animation information files, and uses them to draw animation frames and provide information about the animations.
|
default |
| void animation_manager::draw_frame | ( | render_target * | pCanvas, |
| size_t | iFrame, | ||
| const ::layers & | oLayers, | ||
| int | iX, | ||
| int | iY, | ||
| uint32_t | iFlags, | ||
| animation_effect | patient_effect = animation_effect::none, |
||
| size_t | patient_effect_offset = 0 |
||
| ) | const |
Draw an animation frame.
| pCanvas | The render target to draw onto. |
| iFrame | The frame index to draw (should be in range [0, getFrameCount() - 1]) |
| oLayers | Information to decide what to draw on each layer. An animation is comprised of up to thirteen layers, numbered 0 through 12. Some animations will have different options for what to render on each layer. For example, patient animations generally have the different options on layer 1 as different clothes, so if layer 1 is set to the value 0, they may have their default clothes, and if set to the value 2 or 4 or 6, they may have other clothes. Play with the AnimView tool for a better understanding of layers, though note that while it can draw more than one option on each layer, this class can only draw a single option for each layer. |
| iX | The screen position to use as the animation X origin. |
| iY | The screen position to use as the animation Y origin. |
| iFlags | Zero or more THDrawFlags flags. |
| patient_effect | The animation effect to apply to the patient. |
| patient_effect_offset | The number of ticks to offset the effect animation by. |
| size_t animation_manager::get_animation_count | ( | ) | const |
Get the total number of animations.
| size_t animation_manager::get_first_frame | ( | size_t | iAnimation | ) | const |
Get the index of the first frame of an animation.
| size_t animation_manager::get_frame_count | ( | ) | const |
Get the total number of animation frames.
| void animation_manager::get_frame_extent | ( | size_t | iFrame, |
| const ::layers & | oLayers, | ||
| int * | pMinX, | ||
| int * | pMaxX, | ||
| int * | pMinY, | ||
| int * | pMaxY, | ||
| uint32_t | iFlags | ||
| ) | const |
| size_t animation_manager::get_frame_sound | ( | size_t | iFrame | ) |
| const animation_start_frames & animation_manager::get_named_animations | ( | std::string_view | sName, |
| int | iTilesize | ||
| ) | const |
Retrieve a custom animation by name and tile size.
| sName | Name of the animation. |
| iTilesize | Tile size of the animation. |
| size_t animation_manager::get_next_frame | ( | size_t | iFrame | ) | const |
Get the index of the frame after a given frame.
To draw an animation frame by frame, call get_first_frame() to get the index of the first frame, and then keep on calling get_next_frame() using the most recent return value from get_next_frame() or get_first_frame().
| bool animation_manager::hit_test | ( | size_t | iFrame, |
| const ::layers & | oLayers, | ||
| int | iX, | ||
| int | iY, | ||
| uint32_t | iFlags, | ||
| int | iTestX, | ||
| int | iTestY | ||
| ) | const |
Load free animations.
| pData | Start of the loaded data. |
| iDataLength | Length of the loaded data. |
| bool animation_manager::load_from_th_file | ( | const uint8_t * | pStartData, |
| size_t | iStartDataLength, | ||
| const uint8_t * | pFrameData, | ||
| size_t | iFrameDataLength, | ||
| const uint8_t * | pListData, | ||
| size_t | iListDataLength, | ||
| const uint8_t * | pElementData, | ||
| size_t | iElementDataLength | ||
| ) |
Load original animations.
set_sprite_sheet() must be called before calling this.
| pStartData | Animation first frame indices (e.g. VSTART-1.ANI) |
| iStartDataLength | Length of pStartData. |
| pFrameData | Frame details (e.g. VFRA-1.ANI) |
| iFrameDataLength | Length of pFrameData |
| pListData | Element indices list (e.g. VLIST-1.ANI) |
| iListDataLength | Length of pListData |
| pElementData | Element details (e.g. VELE-1.ANI) |
| iElementDataLength | Length of pElementData |
| void animation_manager::set_animation_alt_palette_map | ( | size_t | iAnimation, |
| const uint8_t * | pMap, | ||
| uint32_t | iAlt32 | ||
| ) |
Set the palette remap data for an animation.
This sets the palette remap data for every single sprite used by the given animation. If the animation (or any of its sprites) are drawn using the thdf_alt_palette flag, then palette indices will be mapped to new palette indices by the 256 byte array pMap. This is typically used to draw things in different colours or in greyscale.
| void animation_manager::set_canvas | ( | render_target * | pCanvas | ) |
Set the video target.
| pCanvas | Video surface to use. |
| void animation_manager::set_sprite_sheet | ( | sprite_sheet * | pSpriteSheet | ) |
| void animation_manager::tick | ( | ) |
Notified every world tick to allow tracking rate of game time passage.