fix scrolllayer culling being broken for nodes with ignoreAnchorPointForPosition

This commit is contained in:
dankmeme01 2025-03-08 19:02:29 +01:00
parent e7d6adeaff
commit b733c3671f

View file

@ -25,10 +25,11 @@ void GenericContentLayer::setPosition(CCPoint const& pos) {
for (auto child : CCArrayExt<CCNode*>(m_pChildren)) {
float childY = this->getPositionY() + child->getPositionY();
float childTop = childY + (1.f - child->getAnchorPoint().y) * child->getScaledContentSize().height;
auto anchor = child->isIgnoreAnchorPointForPosition() ? CCPoint{ 0, 0 } : child->getAnchorPoint();
float childTop = childY + (1.f - anchor.y) * child->getScaledContentSize().height;
float childBottom = childY - child->getAnchorPoint().y * child->getScaledContentSize().height;
bool visible = childTop > 0 && childBottom < scrollLayerSize.height;
child->setVisible(visible);
}
}