更新时间:2023-11-19 15:33:34
我最终使用了 GL_SCISSOR.
I ended up using GL_SCISSOR.
在我实现的 MainSprite 中:
in MainSprite I impemented:
- (void) visit
{
if (!self.visible) {
return;
}
glEnable(GL_SCISSOR_TEST);
glScissor(x, y, width, height);
[super visit];
glDisable(GL_SCISSOR_TEST);
}
这将剪切或遮盖指定区域.
This will clip or mask the specified area.
唯一棘手的一点是,在横向模式下,Cocos2D 在屏幕的左下角有 0,0,而 OpenGL 在右下角有它,因为它不考虑屏幕的方向.
The only tricky bit is that in Landscape mode Cocos2D has 0,0 at the bottom-left side of the screen, while OpenGL has it at the bottom-right corner as it doesn't consider the orientation of the screen.
换句话说,对于 OpenGL,假设您有一个旋转的纵向屏幕.
In other words, for OpenGL consider you have a rotated portrait Screen.