[Cocos2D 09.03]04. 메뉴만들기
2010. 9. 3. 14:42ㆍIPhone/Cocos2D
반응형
1.문자로 메뉴만들기
2. 이미지로 메뉴만들기
[MenuItemFont setFontSize:25]; [MenuItemFont setFontName:@"helvetica"]; MenuItem *start=[MenuItemFont itemFromString:@"시작\n" target:self selector:@selector(startGame:)]; MenuItem *help=[MenuItemFont itemFromString:@"도움말"target:self selector:@selector(help:)]; Menu *menu=[Menu menuWithItems:start,help,nil]; [menu setPosition:ccp(100,150)]; [menu alignItemsVertically]; [self addChild:menu]; |
-(void)startGame:(id)sender { gameScene *gs=[gameScene node]; [[Director sharedDirector] replaceScene:gs]; } -(void)help:(id)sender { helpScene *hs=[helpScene node]; [[Director sharedDirector] replaceScene:hs]; } |
2. 이미지로 메뉴만들기
MenuItemImage *start=[MenuItemImage itemFromNormalImage:@"s1.png" selectedImage:@"s2.png" target:self selector:@selector(starter:)]; MenuItemImage *help=[MenuItemImage itemFromNormalImage:@"h.png" selectedImage:@"h2.png" target:self selector:@selector(help:)]; Menu *menu=[Menu menuWithItems:start,help,nil]; menu.postion=[menu setPosition:ccp(100,150)]; [menu alignItemsVertically]; start.positon=ccp(360,200); help.position=ccp(360,120); [self addChild:menu]; |
-(void)startGame:(id)sender { gameScene *gs=[gameScene node]; [[Director sharedDirector] replaceScene:gs]; } -(void)help:(id)sender { helpScene *hs=[helpScene node]; [[Director sharedDirector] replaceScene:hs]; } |
반응형
'IPhone > Cocos2D' 카테고리의 다른 글
[Cocos2D 09.03]06.DSProject!! (0) | 2010.09.04 |
---|---|
[Cocos2D 09.03]05. AtlasAnimation과 Sprite (0) | 2010.09.03 |
[Cocos2D 09.03]03. 새로운 클래스로 Scene만들기 (0) | 2010.09.03 |
[Cocos2D 09.03]02. 주요클래스의 메소드 (0) | 2010.09.03 |
[Cocos2D 09.03]01. Cocos2D 엔진 (0) | 2010.09.03 |