Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-31-2011, 10:34 PM   #1 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 22
kimd7 is on a distinguished road
Default Cocos2d Menu

Hi,

I am trying to make a menu in my game with cocos2d. Here is my code:

Code:
@implementation HelloWorldLayer

+(id) scene {
    CCScene *scene = [CCScene node];
    HelloWorldLayer *layer = [HelloWorldLayer node];
    [scene addChild: layer];
    return scene;
}

-(id) init
{
     if( (self=[super init])) {
        [CCMenuItemFont setFontName:@"Marker Felt"];
        [CCMenuItemFont setFontSize:35];
        CCMenuItem *item1 = [CCMenuItemFont itemFromString:@"PLAY" target:self selector:@selector(start:)];
        CCMenu *menu = [CCMenu menuWithItems:item1, nil];
        [self addChild:menu];
}
    return self;
}

-(void) start: (id) sender {
    [[CCDirector sharedDirector] replaceScene: [GamePlay node]];
    
}
I want to switch to the "GamePlay" scene after pressing "PLAY", but when I run iPhone Simulator, I press it and nothing happens. Are there any ways to fix this?
kimd7 is offline   Reply With Quote
Old 07-12-2011, 12:48 AM   #2 (permalink)
Beast Mode
 
Join Date: Dec 2008
Age: 21
Posts: 1,971
Bertrand21 is on a distinguished road
Default

Quote:
Originally Posted by kimd7 View Post
Hi,

I am trying to make a menu in my game with cocos2d. Here is my code:

Code:
@implementation HelloWorldLayer

+(id) scene {
    CCScene *scene = [CCScene node];
    HelloWorldLayer *layer = [HelloWorldLayer node];
    [scene addChild: layer];
    return scene;
}

-(id) init
{
     if( (self=[super init])) {
        [CCMenuItemFont setFontName:@"Marker Felt"];
        [CCMenuItemFont setFontSize:35];
        CCMenuItem *item1 = [CCMenuItemFont itemFromString:@"PLAY" target:self selector:@selector(start:)];
        CCMenu *menu = [CCMenu menuWithItems:item1, nil];
        [self addChild:menu];
}
    return self;
}

-(void) start: (id) sender {
    [[CCDirector sharedDirector] replaceScene: [GamePlay node]];
    
}
I want to switch to the "GamePlay" scene after pressing "PLAY", but when I run iPhone Simulator, I press it and nothing happens. Are there any ways to fix this?
Did you ever figure this out? I am having the same issue.
Thanks
__________________
Haters gonna Hate
Likers gonna Like
Bertrand21 is offline   Reply With Quote
Old 07-12-2011, 01:46 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 324
mariano_donati is on a distinguished road
Default

I might be wrong, but I think you need to replace this line

Code:
CCMenuItem *item1 = [CCMenuItemFont itemFromString:@"PLAY" target:self selector:@selector(start:)];
with this one:

Code:
CCMenuItem *item1 = [CCMenuItemFont itemFromString:@"PLAY" target:self selector:@selector(start)];
I remember having the same issue. However, I can't find what was the project I was working on neither the cocos2d docs says much about it.
mariano_donati is offline   Reply With Quote
Reply

Bookmarks

Tags
cocos2d, cocos2d menu, menu

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 334
5 members and 329 guests
Dnnake, iOS.Lover, jenniead38, Kirkout, Wikiboo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:17 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0