From 41cf359468d6379bc0e033bee9ac148d1b9255dd Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Fri, 19 Oct 2007 17:46:46 +0000 Subject: Factored code between resource handlers. Implemented failure-friendly sprite loader. --- src/resources/spritedef.h | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/resources/spritedef.h') diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index 55d7f459..121f23cc 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -71,28 +71,26 @@ class SpriteDef : public Resource { public: /** - * Constructor. + * Loads a sprite definition file. */ - SpriteDef(const std::string &idPath, - const std::string &file, int variant); + static SpriteDef *load(std::string const &file, int variant); /** - * Destructor. + * Returns the specified action. */ - ~SpriteDef(); + Action *getAction(SpriteAction action) const; + + private: /** - * Returns the specified action. + * Constructor. */ - Action* - getAction(SpriteAction action) const; + SpriteDef(): mAction(NULL), mDirection(DIRECTION_DOWN), mLastTime(0) {} - private: /** - * Loads a sprite definition file. + * Destructor. */ - void - load(const std::string &file, int variant); + ~SpriteDef(); /** * Loads an imageset element. @@ -120,6 +118,11 @@ class SpriteDef : public Resource void includeSprite(xmlNodePtr includeNode); + /** + * Complete missing actions by copying existing ones. + */ + void substituteActions(); + /** * When there are no animations defined for the action "complete", its * animations become a copy of those of the action "with". -- cgit v1.2.3-60-g2f50