MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / loadFrame

Method loadFrame

Source/Cache/FrameCache.cpp:18–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16#include "Node/Sprite.h"
17
18NS_DORA_BEGIN
19
20FrameActionDef* FrameCache::loadFrame(String frameStr) {
21 if (Path::getExt(frameStr.toString()) == "frame"_slice) return load(frameStr);
22 BLOCK_START {
23 auto parts = frameStr.split("::"_slice);
24 BREAK_IF(parts.size() != 2);
25 FrameActionDef* def = FrameActionDef::create();
26 def->clipStr = parts.front().toString();
27 Vec2 origin{};
28 if (SharedClipCache.isClip(parts.front())) {
29 auto [_tex, rect] = SharedClipCache.loadTexture(parts.front());
30 origin = rect.origin;
31 }
32 auto tokens = parts.back().split(","_slice);
33 BREAK_IF(tokens.size() != 4);
34 auto it = tokens.begin();
35 float width = it->toFloat();
36 float height = (++it)->toFloat();
37 int count = (++it)->toInt();
38 def->duration = (++it)->toFloat();
39 for (int i = 0; i < count; i++) {
40 def->rects.push_back(New<Rect>(origin.x + i * width, origin.y, width, height));
41 }
42 return def;
43 }
44 BLOCK_END
45 Error("invalid frame str not load: \"{}\".", frameStr.toString());
46 return nullptr;

Callers 2

SpriteVisualMethod · 0.80
setFileMethod · 0.80

Calls 13

isClipMethod · 0.80
loadTextureMethod · 0.80
toFloatMethod · 0.80
loadFunction · 0.70
toStringMethod · 0.65
splitMethod · 0.65
createFunction · 0.50
sizeMethod · 0.45
frontMethod · 0.45
backMethod · 0.45
beginMethod · 0.45
toIntMethod · 0.45

Tested by

no test coverage detected