CCAdvancedMenu boundaryRect

希望有人可以帮助我这个…我在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应该做的。 有没有人使用过,可以给我一些build议?!?

谢谢!

那么,不是从同一个class级,而是一个本土的滚动菜单。 我使用menuItem本身的可见性和透明度。 当向上滚动时,如果一个菜单标签接近矩形的边缘,我开始淡出为0.当menuItem的定位点在矩形之外时,我将其可见性设置为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; } }