I'm trying to make an items scroller of sorts for my game. I decided upon the extension CCMenuAdvanced
, and I was able to implement a working menu list with working buttons. However, I don't quite understand how to properly contain my menu inside a boundaryRect. It is clear to me that boundaryRect does not make "out of bounds" part of the menu list disappear - it seems to only be responsible for scrolling. The question then is what else do I have to do to get a self-contained items list using CCMenuAdvanced
that becomes invisible and unresponsive when no longer in the boundary? Do I have to schedule an additional update method that tracks the location of individual elements and changes their opacity and visibility or is there a supported solution to this?
NSArray *menuItems = [self labelsFromInventory];
CCMenuAdvanced *menu = [CCMenuAdvanced menuWithItems: nil];
for (CCMenuItem *item in menuItems)
[menu addChild: item];
[menu alignItemsVerticallyWithPadding: 10 bottomToTop: NO]; //< also sets contentSize and keyBindings on Mac
//menu.isRelativeAnchorPoint = YES;
menu.position = ccp(30, 40);
[self addChild:menu z:2 tag:101];
menu.scale = MIN ((winSize.width / 2.0f) / menu.contentSize.width, 0.75f );
menu.boundaryRect = CGRectMake(menu.position.x, menu.position.y, 190.0, 20.0);
[menu fixPosition];
Thanks