quick 2.2.3 android
IOS 上是可以的
网上有相关解决方案 Cocos2dxActivity 中设置 setEGLConfigChooser(5, 6, 5, 0, 16, 8) 但是调用这个方法后帧数下降了十几帧。
不知道是否有其他的不影响性能的解决方案?
quick 2.2.3 android
IOS 上是可以的
网上有相关解决方案 Cocos2dxActivity 中设置 setEGLConfigChooser(5, 6, 5, 0, 16, 8) 但是调用这个方法后帧数下降了十几帧。
不知道是否有其他的不影响性能的解决方案?
setClippingType(LAYOUT_CLIPPING_SCISSOR)
设置这个后 getClippingRect 获取的区域是不正确的
靠 setClippingType(LAYOUT_CLIPPING_SCISSOR) 设置后不能修改锚点 。。。。。不然区域不对。锚点必须是(0, 0)
咋样, 修复了没有,Ok了 就总结一下 结贴。
今天只是找到问题了明天解决了再提交PR
今天 花了点时间研究了下 发现 Layout 中的getClippingRect 存在几个bug,
bug1:目前没有考虑锚点为非(0, 0) 的情况
bug2:父节点也是裁剪Layout 获取最后区域有问题
代码如下 红色为修改的地方,大家看看有什么问题没?
const CCRect& Layout::getClippingRect()
{
if (_clippingRectDirty)
{
_handleScissor = true;
CCPoint worldPos = m_obPosition;
if (this->getParent()) {
worldPos = this->getParent()->convertToWorldSpace(m_obPosition);
}
CCAffineTransform t = nodeToWorldTransform();
float scissorWidth = _size.width*t.a;
float scissorHeight = _size.height*t.d;
if (!isIgnoreAnchorPointForPosition()) {
worldPos.x -= scissorWidth * m_obAnchorPoint.x;
worldPos.y -= scissorHeight * m_obAnchorPoint.y;
}
CCRect parentClippingRect;
Layout* parent = this;
bool firstClippingParentFounded = false;
while (parent)
{
parent = dynamic_cast<Layout*>(parent->getParent());
if(parent)
{
if (parent->isClippingEnabled())
{
if (!firstClippingParentFounded)
{
_clippingParent = parent;
firstClippingParentFounded = true;
}
if (parent->_clippingType == LAYOUT_CLIPPING_SCISSOR)
{
_handleScissor = false;
break;
}
}
}
}
if (_clippingParent)
{
parentClippingRect = _clippingParent->getClippingRect();
float finalX = worldPos.x;
float finalY = worldPos.y;
float finalWidth = scissorWidth;
float finalHeight = scissorHeight;
float leftOffset = worldPos.x - parentClippingRect.origin.x;
if (leftOffset < 0.0f)
{
finalX = parentClippingRect.origin.x;
finalWidth -= leftOffset;
}
float rightOffset = (worldPos.x + scissorWidth) - (parentClippingRect.origin.x + parentClippingRect.size.width);
if (rightOffset > 0.0f)
{
finalWidth -= rightOffset;
}
float topOffset = (worldPos.y + scissorHeight) - (parentClippingRect.origin.y + parentClippingRect.size.height);
if (topOffset > 0.0f)
{
finalHeight -= topOffset;
}
float bottomOffset = worldPos.y - parentClippingRect.origin.y;
if (bottomOffset < 0.0f)
{
finalY = parentClippingRect.origin.x;
finalHeight -= bottomOffset;
}
if (finalWidth < 0.0f)
{
finalWidth = 0.0f;
}
if (finalHeight < 0.0f)
{
finalHeight = 0.0f;
}
_clippingRect.origin.x = finalX;
_clippingRect.origin.y = finalY;
_clippingRect.size.width = finalWidth;
_clippingRect.size.height = finalHeight;
}
else
{
_clippingRect.origin.x = worldPos.x;
_clippingRect.origin.y = worldPos.y;
_clippingRect.size.width = scissorWidth;
_clippingRect.size.height = scissorHeight;
}
_clippingRectDirty = false;
}
return _clippingRect;
}
cocos2dx 3.0 上也存在这个bug。
大家都看一下如果是正确的晚上我回去提交PR
感觉没啥问题 顶一个
mark
膜拜