31 auto &frame =
mFrames.emplace_back();
34 frame.offsetX = offsetX;
35 frame.offsetY = offsetY;
47 return candidate.
image ==
nullptr;
54 std::string imagePath = node.
getProperty(
"imageset", std::string());
69 for (
auto frameNode : node.
children())
71 int delay = frameNode.getProperty(
"delay", 0);
72 int offsetX = frameNode.getProperty(
"offsetX", 0);
73 int offsetY = frameNode.getProperty(
"offsetY", 0);
81 if (frameNode.name() ==
"frame")
83 int index = frameNode.getProperty(
"index", -1);
91 Image *img = imageSet->get(index);
99 animation.
addFrame(img, delay, offsetX, offsetY);
101 else if (frameNode.name() ==
"sequence")
103 int start = frameNode.getProperty(
"start", -1);
104 int end = frameNode.getProperty(
"end", -1);
106 if (start < 0 || end < 0)
108 Log::info(
"No valid value for 'start' or 'end'");
114 Image *img = imageSet->get(start);
118 Log::info(
"No image at index %d", start);
122 animation.
addFrame(img, delay, offsetX, offsetY);
126 else if (frameNode.name() ==
"end")
An animation consists of several frames, each with their own delay and offset.
static bool isTerminator(const Frame &phase)
Determines whether the given animation frame is a terminator.
void addFrame(Image *image, int delay, int offsetX, int offsetY)
Appends a new animation at the end of the sequence.
std::vector< Frame > mFrames
ResourceRef< ImageSet > mImageSet
static Animation fromXML(XML::Node node, const std::string &dyePalettes={})
Loads an animation from XML.
void addTerminator()
Appends an animation terminator that states that the animation should not loop.
static void instantiate(std::string &target, const std::string &palettes)
Fills the blank in a dye placeholder with some palette names.
The main class responsible for running the game.
int getCurrentTileWidth() const
Convenience functions used to get the current tile width and height.
int getCurrentTileHeight() const
static Game * instance()
Provides access to the game instance.
Defines a class for loading and storing images.
static ResourceManager * getInstance()
Returns an instance of the class, creating one if it does not already exist.
ResourceRef< ImageSet > getImageSet(const std::string &imagePath, int w, int h)
Loads a image set based on the image referenced by the given path and the supplied sprite sizes.
int getProperty(const char *name, int def) const
Children children() const
void info(const char *log_text,...) LOG_PRINTF_ATTR
A single frame in an animation, with a delay and an offset.