COCOS2D with Opengl coverflow

Forums Programming cocos2d support (graphics engine) COCOS2D with Opengl coverflow

This topic contains 17 replies, has 8 voices, and was last updated by  NEWNATHANIEL 3 years, 7 months ago.

Viewing 18 posts - 1 through 18 (of 18 total)
Author Posts
Author Posts
May 26, 2010 at 8:52 am #221963

jjaaxx44
@jjaaxx44

hi frends,

i have implemented coverflow in my game using some example i found on net

here’s the code to add images and get selected image no.

when i select any image scene do not replace.

when image is selected (FlowCoverView *)view didSelect:(int)image

gets called. and i wrote replace scene in that method, is there anything else ishould add??

can anyone please check my code.

thanx

#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

May 26, 2010 at 9:04 am #283949

jjaaxx44
@jjaaxx44

control is getting into LevelSelectionLayers init and i can see change in sound but no thing on the screen on LevelSelectionLayer

May 26, 2010 at 9:21 am #283950

riq
Keymaster
@admin

Please, post code between backticks ( ` ). Thanks

May 26, 2010 at 2:47 pm #283951

Neo-Dragon
@neo-dragon

Could you post an example project with the image files in a zip just to get a feeler for it please.

May 27, 2010 at 3:22 am #283952

jjaaxx44
@jjaaxx44

where can i upload my zip file??….

i will give you the coverflow example embedded in cocos2d its not my own but found somewhere…it is the same way i have implemented in my game….just you have to add dummy class and replace scene from didSelect method..

May 27, 2010 at 3:44 am #283953

robodude666
@robodude666

I personally like http://filebeam.com/ for sharing files :).

May 27, 2010 at 4:13 am #283954

jjaaxx44
@jjaaxx44

http://filebeam.com/8ffa431741f013ba0b24e35c52c117b8

here’s the code

this code was originally is from http://www.chaosinmotion.com/flowcover.m

dont know who implemented to cocos2d

May 27, 2010 at 10:02 am #283955

jjaaxx44
@jjaaxx44

any leads??

May 28, 2010 at 4:43 pm #283956

jjaaxx44
@jjaaxx44

6 downloads but not a single reply :(

May 28, 2010 at 7:14 pm #283957

GhostDog
@ghostdog

I had the original Flowcover working but within a UIKIt framework of a Cocos2D app. There was a bunch begin/end scene gymnastics I had to go through. I’ll give it a shot tonight and let you know if I have any issues.

May 29, 2010 at 2:47 am #283958

jjaaxx44
@jjaaxx44

thank u very much for efforts….

will wait for your reply…

May 29, 2010 at 5:41 pm #283959

GhostDog
@ghostdog

2 minor issues:

1) I think every developer should have warnings as errors turned on. You have some implicit double to float warnings that won’t compile for those of us who have this setting. Easily fixed.

2) Couldn’t get on the device straight away due to device requirement in the pList (which is weird because I have a 3g) They really aren’t necessary for this sample. Deleted that field and it worked out fine.

May 31, 2010 at 5:24 am #283960

jjaaxx44
@jjaaxx44

is it switching to new scene??

and can you see your new scene without any probs??

May 31, 2010 at 8:31 am #283961

popgoblin
Participant
@popgoblin

it works fine here…?

June 2, 2010 at 3:04 am #283962

jjaaxx44
@jjaaxx44

when i try to switch to next scene it creats problem…

can please upload a the project which switch to next scene which has some animation….

June 4, 2010 at 1:09 pm #283963

jjaaxx44
@jjaaxx44

can anyone help me with this???

August 6, 2010 at 7:12 am #283964

psudheer28
@psudheer28

Hi jjaxx

I am using your code for cover flow but getting same problem in replacing the scene. If you have any solution for that then kindly provide it to me.

Thanks

September 9, 2010 at 8:07 am #283965

NEWNATHANIEL
Participant
@newnathaniel

I have a problem

I use cocos2d 0.99.4.

In he first touchesMoved:the UIView is displace

http://www.doloresentertainment.com/Imagenes/ErrorCoverFlow.png

where is the problem?

thanks

Viewing 18 posts - 1 through 18 (of 18 total)

You must be logged in to reply to this topic.