gpt4 book ai didi

ios - CCAdvancedMenu boundaryRect

转载 作者:行者123 更新时间:2023-11-28 17:32:04 27 4
gpt4 key购买 nike

希望有人能帮我解决这个问题……我在看例子here for CCMenuAdvanced但最终得到了一个奇怪的结果,我看到我的菜单并且它滚动但是使用 boundaryRect 属性我似乎无法让它隐藏部分菜单并显示我想要的内容。

这是我的代码:

// Setup Menu Alignment
[menuA alignItemsVerticallyWithPadding:0 bottomToTop:NO]; //< also sets contentSize and keyBindings on Mac
menuA.isRelativeAnchorPoint = YES;

menuA.boundaryRect = CGRectMake(0, 100, 230, 200);

[menuA fixPosition];
[self addChild:menuA];

我可以滚动并查看我的整个列表,这很好,但我不能设置一个区域一次只查看部分菜单,而 boundaryRect 应该这样做。有没有人以前用过这个并且可以给我一些建议?!?

谢谢!

最佳答案

好吧,不是来自同一个类(class),而是一个本土的滚动菜单。我使用 menuItems 本身的可见性和透明度。向上滚动时,如果菜单标签接近矩形的边缘,我开始将其淡出到 0。当 menuItem 的 anchor 在矩形之外时,我将其可见性设置为 NO(因此无法单击)。一样下去。夹紧很棘手。当 menuItems 列表发生变化时,您必须设置这些属性,以防它变得比边界矩形的高度短,或者再次变得大于矩形。像这样的东西(编辑过的,不是实际的代码......不知道它是否编译:)):

-(void) fixMenuItemOpacity:(CCMenuItemLabel*) mi{

float theY = mi.position.y ;

if (fadeOutZoneHeight_<4.0f) {
if (theY> self.boundaryRect.origin.y+self.boundaryRect.size.height/2 - fadeOutZoneHeight_) {
mi.visible=NO;
} else if( theY < self.boundaryRect.origin.y-self.boundaryRect.size.height/2 + fadeOutZoneHeight_) {
mi.visible=NO;
} else {
mi.visible=YES;
}
return;
}
float delta;
float percentOpacity;

float topWindow;
float bottomWindow;
float top;
float bottom;

/*

not visible

--------------------------- top
visible, variable opacity
--------------------------- top window




opacity 100%




-------------------------- bottomWindow
visible, variable opacity
------------------------- bottom

*/

top = self.boundaryRect.origin.y + self.boundaryRect.size.height/2;
topWindow = top - fadeOutZoneHeight_;
bottom = self.boundaryRect.origin.y - self.boundaryRect.size.height/2;
bottomWindow=bottom+ fadeOutZoneHeight_;

if (theY> top ) {
mi.visible=NO;
} else if ( (theY > topWindow) && (theY < top)) {
mi.visible=YES;
delta = abs((int)top - (int)theY);
percentOpacity=delta/fadeOutZoneHeight_;
mi.opacity=(GLubyte )(255.0f*percentOpacity);
} else if( (theY <= topWindow ) && (theY >= bottomWindow ) ){
mi.opacity=255;
mi.visible=YES;

} else if ( (theY < bottomWindow) && (theY >= bottom) ){
mi.visible=YES;
delta= abs((int)bottom - (int)theY);
percentOpacity = delta/fadeOutZoneHeight_;
mi.opacity=(GLubyte ) (255.0*percentOpacity);
} else {
mi.visible=NO;
}


}

关于ios - CCAdvancedMenu boundaryRect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10936436/

27 4 0
文章推荐: iphone - 如何打破解析结果?
文章推荐: ios - Facebook sdk iOS 图片从请求返回为 nil
文章推荐: ios - 客户端应用程序的 iPhone App Store ID
文章推荐: javascript - 如何在 JavaScript 中编辑