cocos2D 강좌 사이트~
나름 잘되어있음.. 이것보고 실습중~
http://appsnet.co.kr/bbs/cocos2d
//
// Cocos2DAppDelegate.m
// Cocos2D
//
// Created by MOAi on 09. 10. 8..
// Copyright 전북대학교 2009. All rights reserved.
//
#import "Cocos2DAppDelegate.h"
#import "cocos2d.h"
@implementation Cocos2DAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// UIWidow 개체를 생성
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Director에서 사용할 View등록
[[Director sharedDirector] attachInView:window];
// HelloScene 생성
Scene *helloScene = [Scene node];
// hello world 라벨 만들기
Label *helloLabel = [Label labelWithString:@"Hello World of Cocos2d."
fontName:@"Helvetica" fontSize:20.0f];
helloLabel.position = ccp(150,200); // 위치 지정(가운데를 글자의 가운데 부분을 위치시켜야함)
//[helloScene addChild:helloLabel];
// 기본 메뉴 아이템 설정
[MenuItemFont setFontSize:30];
[MenuItemFont setFontName: @"Courier New"];
// 메뉴 아이템
MenuItem *item1 = [MenuItemFont itemFromString: @"시작" target:self selector:@selector(menuStartCallback:)];
MenuItem *item2 = [MenuItemFont itemFromString: @"환경설정" target:self selector:@selector(menuConfigCallback:)];
// 메뉴를 답는 레이어(메뉴는 배열 형식)
Menu *menu = [Menu menuWithItems: item1,item2, nil];
//[menu alignItemsInRows:(NSNumber *)2];
[menu alignItemsInRows:[NSNumber numberWithInt:2],nil];
// 메뉴의 위치설정
//menu.position = ccp(100,300);
// 메뉴들의 위아래 간격 조절
//[menu alignItemsVerticallyWithPadding:100.0f];
// 씬에 메뉴를 추가(메뉴가 레이어를 상속받기때문에 다른 레이어 추가없이 추가 가능)
[helloScene addChild:menu];
// HelloScene을 실행
[[Director sharedDirector] runWithScene:helloScene];
// Override point for customization after application launch
[window makeKeyAndVisible];
}
-(void) menuStartCallback: (id) sender
{
NSLog(@"called start menu");
}
-(void) menuConfigCallback: (id) sender
{
NSLog(@"called config menu");
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end


나름 잘되어있음.. 이것보고 실습중~
http://appsnet.co.kr/bbs/cocos2d
더보기
//
// Cocos2DAppDelegate.m
// Cocos2D
//
// Created by MOAi on 09. 10. 8..
// Copyright 전북대학교 2009. All rights reserved.
//
#import "Cocos2DAppDelegate.h"
#import "cocos2d.h"
@implementation Cocos2DAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// UIWidow 개체를 생성
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Director에서 사용할 View등록
[[Director sharedDirector] attachInView:window];
// HelloScene 생성
Scene *helloScene = [Scene node];
// hello world 라벨 만들기
Label *helloLabel = [Label labelWithString:@"Hello World of Cocos2d."
fontName:@"Helvetica" fontSize:20.0f];
helloLabel.position = ccp(150,200); // 위치 지정(가운데를 글자의 가운데 부분을 위치시켜야함)
//[helloScene addChild:helloLabel];
// 기본 메뉴 아이템 설정
[MenuItemFont setFontSize:30];
[MenuItemFont setFontName: @"Courier New"];
// 메뉴 아이템
MenuItem *item1 = [MenuItemFont itemFromString: @"시작" target:self selector:@selector(menuStartCallback:)];
MenuItem *item2 = [MenuItemFont itemFromString: @"환경설정" target:self selector:@selector(menuConfigCallback:)];
// 메뉴를 답는 레이어(메뉴는 배열 형식)
Menu *menu = [Menu menuWithItems: item1,item2, nil];
//[menu alignItemsInRows:(NSNumber *)2];
[menu alignItemsInRows:[NSNumber numberWithInt:2],nil];
// 메뉴의 위치설정
//menu.position = ccp(100,300);
// 메뉴들의 위아래 간격 조절
//[menu alignItemsVerticallyWithPadding:100.0f];
// 씬에 메뉴를 추가(메뉴가 레이어를 상속받기때문에 다른 레이어 추가없이 추가 가능)
[helloScene addChild:menu];
// HelloScene을 실행
[[Director sharedDirector] runWithScene:helloScene];
// Override point for customization after application launch
[window makeKeyAndVisible];
}
-(void) menuStartCallback: (id) sender
{
NSLog(@"called start menu");
}
-(void) menuConfigCallback: (id) sender
{
NSLog(@"called config menu");
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end
// Cocos2DAppDelegate.m
// Cocos2D
//
// Created by MOAi on 09. 10. 8..
// Copyright 전북대학교 2009. All rights reserved.
//
#import "Cocos2DAppDelegate.h"
#import "cocos2d.h"
@implementation Cocos2DAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// UIWidow 개체를 생성
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Director에서 사용할 View등록
[[Director sharedDirector] attachInView:window];
// HelloScene 생성
Scene *helloScene = [Scene node];
// hello world 라벨 만들기
Label *helloLabel = [Label labelWithString:@"Hello World of Cocos2d."
fontName:@"Helvetica" fontSize:20.0f];
helloLabel.position = ccp(150,200); // 위치 지정(가운데를 글자의 가운데 부분을 위치시켜야함)
//[helloScene addChild:helloLabel];
// 기본 메뉴 아이템 설정
[MenuItemFont setFontSize:30];
[MenuItemFont setFontName: @"Courier New"];
// 메뉴 아이템
MenuItem *item1 = [MenuItemFont itemFromString: @"시작" target:self selector:@selector(menuStartCallback:)];
MenuItem *item2 = [MenuItemFont itemFromString: @"환경설정" target:self selector:@selector(menuConfigCallback:)];
// 메뉴를 답는 레이어(메뉴는 배열 형식)
Menu *menu = [Menu menuWithItems: item1,item2, nil];
//[menu alignItemsInRows:(NSNumber *)2];
[menu alignItemsInRows:[NSNumber numberWithInt:2],nil];
// 메뉴의 위치설정
//menu.position = ccp(100,300);
// 메뉴들의 위아래 간격 조절
//[menu alignItemsVerticallyWithPadding:100.0f];
// 씬에 메뉴를 추가(메뉴가 레이어를 상속받기때문에 다른 레이어 추가없이 추가 가능)
[helloScene addChild:menu];
// HelloScene을 실행
[[Director sharedDirector] runWithScene:helloScene];
// Override point for customization after application launch
[window makeKeyAndVisible];
}
-(void) menuStartCallback: (id) sender
{
NSLog(@"called start menu");
}
-(void) menuConfigCallback: (id) sender
{
NSLog(@"called config menu");
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end
//
// Cocos2DAppDelegate.m
// Cocos2D
//
// Created by MOAi on 09. 10. 8..
// Copyright 전북대학교 2009. All rights reserved.
//
#import "Cocos2DAppDelegate.h"
#import "cocos2d.h"
@implementation Cocos2DAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// UIWidow 개체를 생성
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Director에서 사용할 View등록
[[Director sharedDirector] attachInView:window];
// HelloScene 생성
Scene *helloScene = [Scene node];
// hello world 라벨 만들기
Label *helloLabel = [Label labelWithString:@"Hello World of Cocos2d."
fontName:@"Helvetica" fontSize:20.0f];
helloLabel.position = ccp(150,200); // 위치 지정(가운데를 글자의 가운데 부분을 위치시켜야함)
//[helloScene addChild:helloLabel];
// 기본 메뉴 아이템 설정
[MenuItemFont setFontSize:30];
[MenuItemFont setFontName: @"Courier New"];
// 메뉴 아이템
MenuItem *item1 = [MenuItemFont itemFromString: @"시작" target:self selector:@selector(menuStartCallback:)];
MenuItem *item2 = [MenuItemFont itemFromString: @"환경설정" target:self selector:@selector(menuConfigCallback:)];
// 메뉴를 답는 레이어(메뉴는 배열 형식)
Menu *menu = [Menu menuWithItems: item1,item2, nil];
//[menu alignItemsInRows:(NSNumber *)2];
[menu alignItemsInRows:[NSNumber numberWithInt:2],nil];
// 메뉴의 위치설정
//menu.position = ccp(100,300);
// 메뉴들의 위아래 간격 조절
//[menu alignItemsVerticallyWithPadding:100.0f];
// 씬에 메뉴를 추가(메뉴가 레이어를 상속받기때문에 다른 레이어 추가없이 추가 가능)
[helloScene addChild:menu];
// HelloScene을 실행
[[Director sharedDirector] runWithScene:helloScene];
// Override point for customization after application launch
[window makeKeyAndVisible];
}
-(void) menuStartCallback: (id) sender
{
NSLog(@"called start menu");
}
-(void) menuConfigCallback: (id) sender
{
NSLog(@"called config menu");
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end



'공부 > 0x06 MOBLIE' 카테고리의 다른 글
| 안드로이드 개발환경 구축 (0) | 2010/05/16 |
|---|---|
| [MOAi] cocos2d 음악재생하기 (0) | 2009/10/16 |
| [MOAi] cocos2d 에니메이션 효과 (0) | 2009/10/16 |
| [MOAi] cocos2d 이미지 메뉴 만들기 (0) | 2009/10/16 |
| [MOAi] cocos2d 메뉴만들기 (0) | 2009/10/16 |