Cocos2d is commonly thought of as a game development library and it has been treated as such in much of this book. However, Cocos2d is a robust solution for any 2D application. That said, draggable windows are a common element in many applications. In this example, we will create movable, collapsable menu windows.
Execute the following code:
#import "GameMenuWindow.h" @implementation Ch5_MenuWindows -(CCLayer*) runRecipe { [super runRecipe]; //Initialization windows = [[[NSMutableArray alloc] init] autorelease]; CCNode *windowContainer = [[CCNode alloc] init]; /* Create three menu windows with randomized positions */ GameMenuWindow *window1 = [GameMenuWindow windowWithTitle:@"Window 1" size:CGSizeMake(arc4random()%200+120,arc4random()%100+50)]; window1.position = ccp(arc4random()%100+150,arc4random()%140+100); [windowContainer addChild...