| 208 | } |
| 209 | |
| 210 | void AnimationCache::addAnimationsWithDictionary(const ValueMap& dictionary, std::string_view plist) |
| 211 | { |
| 212 | auto anisItr = dictionary.find("animations"); |
| 213 | if (anisItr == dictionary.end()) |
| 214 | { |
| 215 | AXLOGW("axmol: AnimationCache: No animations were found in provided dictionary."); |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | const Value& animations = anisItr->second; |
| 220 | unsigned int version = 1; |
| 221 | |
| 222 | auto propsItr = dictionary.find("properties"); |
| 223 | if (propsItr != dictionary.end()) |
| 224 | { |
| 225 | const ValueMap& properties = propsItr->second.asValueMap(); |
| 226 | version = properties.at("format").asInt(); |
| 227 | const ValueVector& spritesheets = properties.at("spritesheets").asValueVector(); |
| 228 | |
| 229 | for (const auto& value : spritesheets) |
| 230 | { |
| 231 | std::string path = FileUtils::getInstance()->fullPathFromRelativeFile(value.asString(), plist); |
| 232 | SpriteFrameCache::getInstance()->addSpriteFramesWithFile(path); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | switch (version) |
| 237 | { |
| 238 | case 1: |
| 239 | parseVersion1(animations.asValueMap()); |
| 240 | break; |
| 241 | case 2: |
| 242 | parseVersion2(animations.asValueMap()); |
| 243 | break; |
| 244 | default: |
| 245 | AXASSERT(false, "Invalid animation format"); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | /** Read an NSDictionary from a plist file and parse it automatically for animations */ |
| 250 | void AnimationCache::addAnimationsWithFile(std::string_view plist) |
nothing calls this directly
no test coverage detected