먼저 iAd.framework 를 추가 하는 부분은 인터넷에서 많이 찾아 볼수 있는 정보 이니 생략 하겠습니다.

2주 전만 해도 정보가 많이 부족 했는데 최근 들어서 iAd관련 하여 정보가 많이 올라 오고 있는것으로 보입니다.

아직까지 미국에서만 된다니 한국에서는 테스트 조차도 못해보는 ㅠㅠ

일반 게임을 만들시에 많은 분들이 cocos2D를 많이 사용 하시는 분들이 계신다 

그 분들을 위해서 cocos2D에서 iAd를 사용 하는법을 잠시 적겠습니다.

cocos2D를 사용 하여 임시적으로 하나의 프로젝트를 생성 합니다.

일반 프로젝트를 생성 하면 나오는 Hello World 프로젝트 입니다. 밑에 부분은 많이 봤을 것입니다.

if( (self=[super init] )) 

{

//cocos2D는 Layer이나 Scene이나 Node를 상속 받아서 사용 합니다.

//View단에서 움직이는 부분이 없으므로 

//ViewController를 동적 생성 해줍니다.

//ADBannerView도 역시 동적 생성 해줍니다.

UIViewController *controller = [[UIViewController alloc]init];   //동적 생성.

controller.view.frame = CGRectMake(0,0,480,320);                 //Hello World가로 방향 

ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectZero];

adView.requiredContentSizeIdentifiers  =                      [NSSet setWithObject:ADBannerContentSizeIdentifier480x32];

adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier480x32;//ADBannerContentSizeIdentifier480*32;

       [controller.view addSubview:adView];    //View 위에 배너를 add하시면 됩니다.

       [[[CCDirector sharedDirector] openGLView] addSubview:controller.view];

// create and initialize a Label

        CCLabel* label = [CCLabel labelWithString:@"Hello World" fontName:@"Marker Felt"                        fontSize:64];


// ask director the the window size

CGSize size = [[CCDirector sharedDirector] winSize];

// position the label on the center of the screen

label.positionccp( size.width /2 , size.height/2 );

// add the label as a child to this Layer

[self addChild: label];

}

////////////*지금 View 및 Banner 두개다 동적할당을 하였기 때문에 delloc 에서 release를 잊으시면 안될꺼 같아 보입니다.  *

//======================================================================================
일반 프로젝트의 Banner추가 방법 입니다. cocos2D를 사용 하지 않았으므로 View위에서 실행 될것으로 압니다.

ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectZero];

adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];

//adView.delegate = self;

adView.frame = CGRectMake(0,430,320,50);

[self addSubview:adView];


//========================================================================================
이 부분도 release를 꼭 해주어야 할꺼 같네요.. ^^ 이상 입니다..~!~!~!

+ Recent posts