From c9337218ef1660360097928c753bde1c79775618 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Tue, 23 Aug 2011 07:52:24 -0400 Subject: Added scrolling to level selection screen Using http://www.xcombinator.com/2010/09/08/a-paging-uiscrollview-in-cocos2d-with-previews/ as a base, I was able to implement a paging scroller for the level selection screen so players can swipe through available levels and choose one to play. At this point, the level selection screen is practically done--the only other thing I want to add is a UIPageControl to interact with the scrolling and give the player an indication of how many levels there are. Refs #207 --- Classes/NMPanelMenu.m | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 Classes/NMPanelMenu.m (limited to 'Classes/NMPanelMenu.m') diff --git a/Classes/NMPanelMenu.m b/Classes/NMPanelMenu.m new file mode 100755 index 0000000..ee24279 --- /dev/null +++ b/Classes/NMPanelMenu.m @@ -0,0 +1,37 @@ +/* + * NMPanelMenu.m + * shapes + * + * Created by Nate Murray on 7/29/10. + * Copyright 2010 YetiApps. All rights reserved. + * + */ + +#import "NMPanelMenu.h" + +@implementation NMPanelMenu + +-(CCMenuItem *) itemForTouch: (UITouch *) touch +{ + CGPoint touchLocation = [touch locationInView: [[touch view] superview]]; + touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation]; + + CCMenuItem* item; + CCARRAY_FOREACH(children_, item){ + // ignore invisible and disabled items: issue #779, #866 + if ( [item visible] && [item isEnabled] ) { + + CGPoint local = [item convertToNodeSpace:touchLocation]; + + CGRect r = [item rect]; + r.origin = CGPointZero; + + if( CGRectContainsPoint( r, local ) ) { + return item; + } + } + } + return nil; +} + +@end -- cgit 1.4.1