MCPcopy Create free account
hub / github.com/axmolengine/axmol / addAnimationsWithDictionary

Method addAnimationsWithDictionary

core/2d/AnimationCache.cpp:210–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208}
209
210void 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 */
250void AnimationCache::addAnimationsWithFile(std::string_view plist)

Callers

nothing calls this directly

Calls 8

getInstanceFunction · 0.85
asIntMethod · 0.80
asStringMethod · 0.80
findMethod · 0.45
endMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected