-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UiLayout is not a necessary getClippingRect correction #19890
Comments
@minggo I just ran into this issue as well. It's easy to reproduce. The problem only occurs if we use This code reproduces it:
If you change the clipping type to As @Rofl113 pointed out, this calculation in
The origin x and y will not be correct. The solution that seems to work is this:
There is other code in
Should be:
The _clippingParent section is only entered if the parent and child nodes are both being clipped, and you can reproduce it with this example:
|
* Fix for issue cocos2d#19890 * Updated with better fix from the V3 PR cocos2d#18651 * Formatting fix * Fixed issue with incorrect type (double instead of float) when compiling on certain platforms. * Another attempt to fix compilation issue
Sequencing:
1.1 Create UiListView
1.2 Set Anchor Point (0.0, 1.0)
1.3 UiLayout::setClippingType(ClippingType::SCISSOR);
1.4 Total: Anchor Point counted twice
Possible location of the problem:
2.1 Layout::getClippingRect
UiLayout (ClippingType::SCISSOR) call func Layout::getClippingRect()
If _clippingParent == nullptr:
_clippingRect.origin.x = worldPos.x - (scissorWidth * _anchorPoint.x); _clippingRect.origin.y = worldPos.y - (scissorHeight * _anchorPoint.y); _clippingRect.size.width = scissorWidth; _clippingRect.size.height = scissorHeight;
2.2 But the amendment (Anchor Point) is already inside the function convertToWorldSpace:
Vec2 worldPos = convertToWorldSpace(Vec2::ZERO);
Possible Solution:
3.1 Correct function Layout::getClippingRect()
If _clippingParent == nullptr:
_clippingRect.origin.x = worldPos.x; _clippingRect.origin.y = worldPos.y; _clippingRect.size.width = scissorWidth; _clippingRect.size.height = scissorHeight;
The text was updated successfully, but these errors were encountered: