mirror of https://github.com/axmolengine/axmol.git
Revert "remove CCClippingRectangleNode transform error support."
This commit is contained in:
parent
731373b93d
commit
eb480fb021
|
@ -42,11 +42,21 @@ void ClippingRectangleNode::onBeforeVisitScissor()
|
|||
if (_clippingEnabled) {
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
float scaleX = _scaleX;
|
||||
float scaleY = _scaleY;
|
||||
Node *parent = this->getParent();
|
||||
while (parent) {
|
||||
scaleX *= parent->getScaleX();
|
||||
scaleY *= parent->getScaleY();
|
||||
parent = parent->getParent();
|
||||
}
|
||||
|
||||
const Point pos = convertToWorldSpace(Point(_clippingRegion.origin.x, _clippingRegion.origin.y));
|
||||
GLView* glView = Director::getInstance()->getOpenGLView();
|
||||
glView->setScissorInPoints(_clippingRegion.origin.x,
|
||||
_clippingRegion.origin.y,
|
||||
_clippingRegion.size.width,
|
||||
_clippingRegion.size.height);
|
||||
glView->setScissorInPoints(pos.x * scaleX,
|
||||
pos.y * scaleY,
|
||||
_clippingRegion.size.width * scaleX,
|
||||
_clippingRegion.size.height * scaleY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
return _clippingRegion;
|
||||
}
|
||||
/**
|
||||
@brief Set the clipping rectangle. The rectangle is base on screen coordinate, so ClippingRectangleNode's region doesn't support any transforms, such as setScale, setRotate and so on.
|
||||
@brief Set the clipping rectangle.
|
||||
@param clippingRegion Specify the clipping rectangle.
|
||||
*/
|
||||
void setClippingRegion(const Rect& clippingRegion);
|
||||
|
|
|
@ -1059,7 +1059,6 @@ std::string ClippingRectangleNodeTest::subtitle() const
|
|||
|
||||
void ClippingRectangleNodeTest::setup()
|
||||
{
|
||||
//Notice: The rectangle is base on screen coordinate, so ClippingRectangleNode's region doesn't support any transforms, such as setScale, setRotate and so on.
|
||||
auto clipper = ClippingRectangleNode::create();
|
||||
clipper->setClippingRegion(Rect(this->getContentSize().width / 2 - 100, this->getContentSize().height / 2 - 100, 200, 200));
|
||||
clipper->setTag( kTagClipperNode );
|
||||
|
@ -1068,6 +1067,6 @@ void ClippingRectangleNodeTest::setup()
|
|||
auto content = Sprite::create(s_back2);
|
||||
content->setTag( kTagContentNode );
|
||||
content->setAnchorPoint( Vec2(0.5, 0.5) );
|
||||
clipper->setPosition(this->getContentSize().width / 2, this->getContentSize().height / 2);
|
||||
content->setPosition(this->getContentSize().width / 2, this->getContentSize().height / 2);
|
||||
clipper->addChild(content);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue