Revision: 39760
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 20, 2011 16:37 by willwish
Initial Code
#import "HelloWorldScene.h" #import "MenuScene.h" #import "Common.h" #import "GameScene.h" UIWindow *flowCoverWindow; UIView *flowCoverView; NSString *currentImage; NSString *previousImage; #define kImageTag 0x01 @implementation FlowCoverViewController - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight)); } - (int)flowCoverNumberImages:(FlowCoverView *)view { return 6; } - (IBAction)done:(id)sender { NSLog(@"done"); [[self parentViewController] dismissModalViewControllerAnimated:YES]; [[Director sharedDirector] resume]; } - (UIImage *)flowCover:(FlowCoverView *)view cover:(int)image { switch (image) { case 0: default: return [UIImage imageNamed:@"dButton1.png"]; case 1: return [UIImage imageNamed:@"dButton2.png"]; case 2: return [UIImage imageNamed:@"dButton3.png"]; case 3: return [UIImage imageNamed:@"dButton4.png"]; case 4: return [UIImage imageNamed:@"dButton5.png"]; case 5: return [UIImage imageNamed:@"dButton6.png"]; } } - (void)flowCover:(FlowCoverView *)view didSelect:(int)image { NSLog(@"Selected Index %d",image); [[self parentViewController] dismissModalViewControllerAnimated:YES]; [[Director sharedDirector] resume]; [[[Director sharedDirector] openGLView] removeFromSuperview]; currentTerrain = image; Scene *s2 = [Scene node]; [s2 addChild: [LevelSelectionLayer node]]; [[Director sharedDirector] replaceScene: s2]; } @end // HelloWorld implementation @implementation HelloWorld +(id) scene { // 'scene' is an autorelease object. Scene *scene = [Scene node]; // 'layer' is an autorelease object. HelloWorld *layer = [HelloWorld node]; // add layer as a child to scene [scene addChild: layer]; // return the scene return scene; } // on "init" you need to initialize your instance -(id) init { if( (self=[super init] )) { } [self ShowCoverFlow]; currentImage = @"icon.png"; previousImage = @"f"; testImage = [Sprite spriteWithFile:currentImage ]; [testImage setPosition:ccp(60,70)]; //[self addChild:testImage z:1 tag:kImageTag]; [self schedule: @selector(UpdateImage:) interval:1/60.0f]; [self MoveImage]; return self; } -(void)MoveImage { id moveSpriteCW = [RotateBy actionWithDuration:3 angle:360]; id moveSpriteCCW = [RotateBy actionWithDuration:1 angle:180]; id seq1 = [Sequence actions: moveSpriteCW, moveSpriteCCW, nil]; id seq2 = [seq1 reverse]; [testImage runAction: [Sequence actions: seq1, seq2, nil]]; } -(void)UpdateImage:(id) sender{ NSLog(@"currentImage is = %@", currentImage); } -(void) ShowCoverFlow { UINavigationController *testViewController; FlowCoverViewController *flowCover; flowCoverView = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; //using a navigation controller to present FlowCover without it rotating to portrait testViewController = [[UINavigationController alloc] init]; //The navigation controller will try to put a nav bar in the window, so we hide it [testViewController setNavigationBarHidden:YES animated:NO]; [testViewController setView:flowCoverView]; NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"TestFC" owner:self options:nil]; flowCover = [array objectAtIndex:0]; testViewController.delegate = self; [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]; [[[Director sharedDirector] openGLView] addSubview:flowCoverView]; [[Director sharedDirector] pause]; [testViewController presentModalViewController:flowCover animated:YES]; } // on "dealloc" you need to release all your retained objects - (void) dealloc { [super dealloc]; } @end
Initial URL
http://www.cocos2d-iphone.org/forum/topic/6653
Initial Description
Initial Title
COCOS2D with Opengl coverflow
Initial Tags
Initial Language
iPhone