Created
March 29, 2012 03:43
-
-
Save l4u/2233073 to your computer and use it in GitHub Desktop.
Layer Clipping cocos2d-x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://codewars.net/304/layer-clipping-in-cocos2d-x/ | |
void CCClippingLayer::visit() | |
{ | |
// quick return if not visible | |
if (!getIsVisible()) | |
{ | |
return; | |
} | |
glPushMatrix(); | |
glEnable(GL_SCISSOR_TEST); | |
CCEGLView::sharedOpenGLView().setScissorInPoints( // scissorRect is the rectangle you want to show. | |
clippingRegion.origin.x + getPosition().x, clippingRegion.origin.y + getPosition().y, | |
clippingRegion.size.width, clippingRegion.size.height); | |
CCNode::visit(); | |
glDisable(GL_SCISSOR_TEST); | |
glPopMatrix(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment