summaryrefslogtreecommitdiff
path: root/ContentBuildingReader.cpp
diff options
context:
space:
mode:
authorKris Parker2009-11-28 08:35:38 +0000
committerKris Parker2009-11-28 08:35:38 +0000
commit41d8e60582918ffcbdb5c2cfb44820388e8b3dd8 (patch)
tree97689282f7137a17cf7366788d52162a80a6b657 /ContentBuildingReader.cpp
parent4f005fb21660aacb15ede433c6244ac48d674c5b (diff)
downloadstonesense-41d8e60582918ffcbdb5c2cfb44820388e8b3dd8.tar.gz
stonesense-41d8e60582918ffcbdb5c2cfb44820388e8b3dd8.tar.bz2
stonesense-41d8e60582918ffcbdb5c2cfb44820388e8b3dd8.tar.xz
Smoother animation system.
Diffstat (limited to 'ContentBuildingReader.cpp')
-rw-r--r--ContentBuildingReader.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/ContentBuildingReader.cpp b/ContentBuildingReader.cpp
index 05a4228..fda047a 100644
--- a/ContentBuildingReader.cpp
+++ b/ContentBuildingReader.cpp
@@ -134,6 +134,25 @@ int parseConditionNode(ConditionalNode* node, TiXmlElement* elemCondition, bool
return -1;
}
+// converts list of characters 0-5 into bits, ignoring garbage
+// eg "035" or "0 3 5" or "0xx3x5" are all good
+inline char getAnimFrames(const char* framestring)
+{
+ if (framestring == NULL)
+ return 1+2+4+8+16+32;
+ char aframes=0;
+ for (int i=0;i<6;i++)
+ {
+ if (framestring[i]==0)
+ return aframes;
+ char temp = framestring[i]-'0';
+ if (temp < 0 || temp > 5)
+ continue;
+ aframes = aframes | (1 << temp);
+ }
+ return aframes;
+}
+
inline bool readNode(SpriteNode* node, TiXmlElement* elemNode, TiXmlElement* elemParent, SpriteBlock* &oldSibling)
{
const char* strType = elemNode->Value();
@@ -189,6 +208,11 @@ inline bool readNode(SpriteNode* node, TiXmlElement* elemNode, TiXmlElement* ele
const char* strOffsetX = elemNode->Attribute("offsetx");
const char* strOffsetY = elemNode->Attribute("offsety");
const char* filename = elemNode->Attribute("file");
+ getAnimFrames(elemNode->Attribute("frames"));
+ sprite->sprite.animFrames = getAnimFrames(elemNode->Attribute("frames"));
+ if (sprite->sprite.animFrames == 0)
+ sprite->sprite.animFrames = 1+2+4+8+16+32;
+
sprite->sprite.sheetIndex = (strSheetIndex != 0 ? atoi(strSheetIndex) : -1);
sprite->sprite.x = (strOffsetX != 0 ? atoi(strOffsetX) : 0);
sprite->sprite.y = (strOffsetY != 0 ? atoi(strOffsetY) : 0);