fix: Scale9Sprite test case 18 (#16897) (#16902)

* fix: Scale9Sprite test case 18

Bug calculating rotated frames.
the width was being used instead of the height and vice-versa

* fixes test cases 8 and 9
This commit is contained in:
Ricardo Quesada 2016-11-24 17:27:20 -08:00 committed by minggo
parent 81f854e82e
commit fce13ba607
2 changed files with 12 additions and 9 deletions

View File

@ -529,13 +529,6 @@ void Sprite::updatePoly()
//
// textCoords Data: Y must be inverted.
//
const float u0 = oox + osw * 0;
const float u1 = oox + osw * cx1;
const float u2 = oox + osw * cx2;
const float v0 = ooy + osh - (osh * cy1);
const float v1 = ooy + osh * (1 - cy2);
const float v2 = ooy + osh * 0;
const float w0 = osw * cx1;
const float w1 = osw * (cx2-cx1);
const float w2 = osw * (1-cx2);
@ -543,6 +536,14 @@ void Sprite::updatePoly()
const float h1 = osh * (cy2-cy1);
const float h2 = osh * (1-cy2);
const float u0 = oox;
const float u1 = u0 + w0;
const float u2 = u1 + w1;
const float v2 = ooy;
const float v1 = v2 + h2;
const float v0 = v1 + h1;
const Rect texRects_normal[9] = {
Rect(u0, v0, w0, h0), // bottom-left
Rect(u1, v0, w1, h0), // bottom

View File

@ -501,8 +501,10 @@ void Scale9Sprite::setCapInsets(const cocos2d::Rect &insetsCopy)
// use _rect coordinates. recenter origin to calculate the
// intersecting rectangle
insets.origin.x -= _offsetPosition.x;
insets.origin.y -= _offsetPosition.y;
// can't use _offsetPosition since it is calculated using bottom-left as origin,
// and the center rect is calculated using top-left
insets.origin.x -= (_originalContentSize.width - _rect.size.width) / 2 + _unflippedOffsetPositionFromCenter.x;
insets.origin.y -= (_originalContentSize.height - _rect.size.height) / 2 - _unflippedOffsetPositionFromCenter.y;
// intersecting rectangle
const float x1 = std::max(insets.origin.x, 0.0f);