void Box9Sprite::animFrameChanged(const AnimationFrame &f) { _prepared = false; ResAnim *resanim = f.getResAnim(); if (resanim) { float scaleFactor = resanim->getScaleFactor(); pugi::xml_attribute attr = resanim->getAttribute("guideX1"); if (!attr.empty()) _guideX[0] = attr.as_float() * scaleFactor; attr = resanim->getAttribute("guideX2"); if (!attr.empty()) _guideX[1] = attr.as_float() * scaleFactor; attr = resanim->getAttribute("guideY1"); if (!attr.empty()) _guideY[0] = attr.as_float() * scaleFactor; attr = resanim->getAttribute("guideY2"); if (!attr.empty()) _guideY[1] = attr.as_float() * scaleFactor; attr = resanim->getAttribute("vertical"); if (!attr.empty()) _vertMode = (StretchMode)attr.as_uint(); attr = resanim->getAttribute("horizontal"); if (!attr.empty()) _horzMode = (StretchMode)attr.as_uint(); } }
void Sprite::changeAnimFrame(const AnimationFrame& frame) { if (_flags & flag_manageResAnim) { ResAnim* rs = _frame.getResAnim(); if (rs) rs->getAtlas()->unload(); rs = frame.getResAnim(); if (rs) rs->getAtlas()->load(); } _frame = frame; setSize(_frame.getSize()); animFrameChanged(_frame); }
void Sprite::changeAnimFrame(const AnimationFrame& frame) { if (_flags & flag_manageResAnim) { ResAnim* rs = _frame.getResAnim(); if (rs) rs->getAtlas()->unload(); rs = frame.getResAnim(); if (rs) rs->getAtlas()->load(); } bool flipX = (_flags & flag_flipX) != 0; bool flipY = (_flags & flag_flipY) != 0; if (flipX || flipY) _frame = frame.getFlipped(flipY, flipX); else _frame = frame; _setSize(_frame.getSize().mult(_localScale)); animFrameChanged(_frame); }