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

Method SpriteVisual

Source/Platformer/VisualCache.cpp:219–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219SpriteVisual::SpriteVisual(String filename)
220 : _isAutoRemoved(false)
221 , _sprite(nullptr)
222 , _action(nullptr) {
223 if (FrameActionDef* frameActionDef = SharedFrameCache.loadFrame(filename)) {
224 if (Texture2D* tex = SharedTextureCache.load(frameActionDef->clipStr)) {
225 _sprite = Sprite::create(tex, *frameActionDef->rects[0]);
226 Action* action = Action::create(FrameAction::alloc(frameActionDef));
227 WRef<SpriteVisual> self{this};
228 _sprite->slot("ActionEnd"_slice, [self, action](Event* event) {
229 Action* eventAction = nullptr;
230 Node* target = nullptr;
231 if (event->get(eventAction, target) && action == eventAction) {
232 if (self) {
233 self->_sprite->setVisible(false);
234 if (self->_isAutoRemoved) {
235 self->removeFromParent(true);
236 }
237 }
238 }
239 });
240 _action = action;
241 }
242 }
243}
244
245bool SpriteVisual::init() {
246 if (!Visual::init()) return false;

Callers

nothing calls this directly

Calls 8

loadFrameMethod · 0.80
removeFromParentMethod · 0.80
loadMethod · 0.65
getMethod · 0.65
createFunction · 0.50
allocFunction · 0.50
slotMethod · 0.45
setVisibleMethod · 0.45

Tested by

no test coverage detected