역시 extable 키 값을 각각 지정 해주시면 됩니다. ^^아래의 값은 임시 적입니다.~


const unsigned char extable[4] = {0x1D, 0x1D, 0x1B, 0xF1};


void IntToByte(int num, unsigned char* value)

{

    value[0] = ((unsigned char)(num >> 24)) ^ extable[0];

    value[1] = ((unsigned char)(num >> 16)) ^ extable[1];

    value[2] = ((unsigned char)(num >> 8)) ^ extable[2];

    value[3] = ((unsigned char)(num)) ^ extable[3];

}


void IntToByteNon(int num, unsigned char* value)

{

    value[0] = ((unsigned char)(num >> 24));

    value[1] = ((unsigned char)(num >> 16));

    value[2] = ((unsigned char)(num >> 8));

    value[3] = ((unsigned char)(num));

}


int ByteToInt(unsigned char* value)

{

    int retV = 0;

    

    retV = (((value[0] & 0xFF) ^ extable[0]) << 24) |

    (((value[1] & 0xFF) ^ extable[1]) << 16) |

    (((value[2] & 0xFF) ^ extable[2]) << 8) |

    ((value[3] & 0xFF) ^ extable[3]);

    

    return retV;

}


int ByteToIntNon(unsigned char* value)

{

    int retV = 0;

    

    retV = (((value[0] & 0xFF)) << 24) |

    (((value[1] & 0xFF)) << 16) |

    (((value[2] & 0xFF)) << 8) |

    ((value[3] & 0xFF));

    

    return retV;

}


- (int) setInt_XOR:(int)value {

    IntToByte(value,_changeBuf);

    return ByteToIntNon(_changeBuf);

}


- (int) getInt_XOR:(int)value {

    memset(_changeBuf, 0x00, 4);

    IntToByteNon(value,_changeBuf);

    return ByteToInt(_changeBuf);

}

일단 파일로 첨부된 파일을 프로젝트에 추가 시킵니다. 이 파일은 인터넷에서 많이 돌아 다니는 게임센터를 따로 클래스 별로 
모아 놓은 형식입니다. 아주 잘 되어 있는데 필요 한 부분이 있으면 사용자가 추가 하면서 하면 될꺼 같습니다.

저는 cocos2d에서 Game Center의 구동을 위해서 view 방식을 바꾸어 놓은 상태 입니다.
아마 show~!~!~ 하는 함수들의 주석을 지우고 openGL의 view 방식을 주석 처리 하시면 일반 view에서 사용 하실수 있습니다.

그리고 제가 따로 추가 한 부분이

-(void)retrivePlayScore 이 부분이 유져의 점수를 가져 오는 부분 입니다.
            조금만 더 바꾸시면 유저의 아이디 랭킹도 가져 올수 있습니다. ^^

궁금한점이 있으시면 ~!~! 댓글 달아 주세요 ^^ 

http://www.cocos2d-iphone.org/forum/topic/8424
http://www.admob.com
애드몹을 사용 하시기 위해서는 위의 사이트에서 등록 하여 고유 넘버 키를 받으셔야 사용이가능 합니다.
참고 사이트 입니다.


=============================================================================
AdViewController.h
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
#import "AdMobDelegateProtocol.h"

@protocol AdViewControllerDelegate;

@interface AdViewController : UIViewController <ADBannerViewDelegate, AdMobDelegate>
{
	id <AdViewControllerDelegate> delegate;
	id adBannerView;

	AdMobView* adMobAd;
}

@property (nonatomic, assign) id <AdViewControllerDelegate> delegate;

- (id)initWithMasterView:(UIView*)masterView;
- (void)rotateBannerView:(UIDeviceOrientation)toDeviceOrientation;

@end

@protocol AdViewControllerDelegate

- (void)adController:(AdViewController*)controller didLoadiAd:(id)iadBanner;
- (void)adController:(AdViewController*)controller didFailedToRecieveiAd:(id)iadBanner;

- (void)adController:(AdViewController*)controller didLoadAdMobAd:(AdMobView*)adMobBanner;
- (void)adController:(AdViewController*)controller didFailedToRecieveAdMobAd:(AdMobView*)adMobBanner;

@end

AdViewController.m

#import "AdViewController.h"
#import "cocos2d.h"

#import "AdMobView.h"

@implementation AdViewController

@synthesize delegate;

- (UIDeviceOrientation)currentOrientation
{
	return [[CCDirector sharedDirector] deviceOrientation];
}

- (id) initWithMasterView:(UIView*) masterView
{
	if( nil != (self = [super init]) )
	{
		[self setView:masterView];

		//Initialize the class manually to make it compatible with iOS < 4.0
		Class classAdBannerView = NSClassFromString(@"ADBannerView");
		if (classAdBannerView != nil)
		{
			adBannerView = [[classAdBannerView alloc] initWithFrame:CGRectZero];
			[adBannerView setDelegate:self];
			[adBannerView setRequiredContentSizeIdentifiers: [NSSet setWithObjects:
															  ADBannerContentSizeIdentifier320x50,
															  ADBannerContentSizeIdentifier480x32, nil]];

			[self.view addSubview:adBannerView];

			[self rotateBannerView:[self currentOrientation]];

			[adBannerView setHidden:YES];

		}
		else
		{
			//Request an AdMob Ad
			adMobAd = [AdMobView requestAdOfSize:ADMOB_SIZE_320x48 withDelegate:self];
			[adMobAd retain];
		}
	}

	return self;
}

- (void)rotateBannerView:(UIDeviceOrientation)toDeviceOrientation
{
	if (adBannerView)
	{
		if (UIDeviceOrientationIsLandscape(toDeviceOrientation))
			[adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifier480x32];
		else
			[adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifier320x50];

		[(UIView*)adBannerView setTransform:CGAffineTransformIdentity];

		//Set the transformation for each orientation
		switch (toDeviceOrientation)
		{
			case UIDeviceOrientationPortrait:
			{
				[(UIView*)adBannerView setCenter:CGPointMake(160, 455)];
			}
				break;
			case UIDeviceOrientationPortraitUpsideDown:
			{
				[(UIView*)adBannerView setTransform:CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(180))];
				[adBannerView setCenter:CGPointMake(160, 25)];
			}
				break;
			case UIDeviceOrientationLandscapeLeft:
			{
				[(UIView*)adBannerView setTransform:CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90))];
				[adBannerView setCenter:CGPointMake(16, 240)];
			}
				break;
			case UIDeviceOrientationLandscapeRight:
			{
				[(UIView*)adBannerView setTransform:CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(-90))];
				[adBannerView setCenter:CGPointMake(304, 240)];
			}
				break;
			default:
				break;
		}
	}

	if (adMobAd)
	{
		[adMobAd setTransform:CGAffineTransformIdentity];

		//Set the transformation for each orientation
		switch (toDeviceOrientation)
		{
			case UIDeviceOrientationPortrait:
			{
				[adMobAd setCenter:CGPointMake(160, 456)];
			}
				break;
			case UIDeviceOrientationPortraitUpsideDown:
			{
				[adMobAd setTransform:CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(180))];
				[adMobAd setCenter:CGPointMake(160, 24)];
			}
				break;
			case UIDeviceOrientationLandscapeLeft:
			{
				[adMobAd setTransform:CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90))];
				[adMobAd setCenter:CGPointMake(24, 240)];
			}
				break;
			case UIDeviceOrientationLandscapeRight:
			{
				[adMobAd setTransform:CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(-90))];
				[adMobAd setCenter:CGPointMake(296, 240)];
			}
				break;
			default:
				break;
		}
	}
}

#pragma mark -
#pragma mark ADBannerViewDelegate

- (BOOL)allowActionToRun
{
	return YES;
}

- (void) stopActionsForAd
{
	//Pause background music here

	[adBannerView setHidden:YES];

	[[CCDirector sharedDirector] stopAnimation];
	[[CCDirector sharedDirector] pause];
}

- (void) startActionsForAd
{
	//Resume background music here

	[self rotateBannerView:[self currentOrientation]];
	[[UIApplication sharedApplication] setStatusBarOrientation:(UIInterfaceOrientation)[self currentOrientation]];
	[adBannerView setHidden:NO];

	[[CCDirector sharedDirector] stopAnimation];
	[[CCDirector sharedDirector] resume];
	[[CCDirector sharedDirector] startAnimation];
}

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
	BOOL shouldExecuteAction = [self allowActionToRun];
    if (!willLeave && shouldExecuteAction)
    {
		[self stopActionsForAd];
    }
    return shouldExecuteAction;
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
	[adBannerView setHidden:NO];
	[delegate adController:self didLoadiAd:banner];
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
	[adBannerView setHidden:YES];
	[delegate adController:self didFailedToRecieveiAd:banner];
}

- (void)bannerViewActionDidFinish:(ADBannerView *)banner
{
	[self startActionsForAd];
}

#pragma mark -
#pragma mark AdMobDelegate methods

- (NSString *)publisherIdForAd:(AdMobView *)adView
{
	return @"your_admob_publisher_id";    //replace it with you publisher id
}

- (UIViewController *)currentViewControllerForAd:(AdMobView *)adView {
	return self;
}

- (UIColor *)adBackgroundColorForAd:(AdMobView *)adView
{
	return [UIColor colorWithRed:0 green:0 blue:0 alpha:1]; // this should be prefilled; if not, provide a UIColor
}

- (UIColor *)primaryTextColorForAd:(AdMobView *)adView
{
	return [UIColor colorWithRed:1 green:1 blue:1 alpha:1]; // this should be prefilled; if not, provide a UIColor
}

- (UIColor *)secondaryTextColorForAd:(AdMobView *)adView
{
	return [UIColor colorWithRed:1 green:1 blue:1 alpha:1]; // this should be prefilled; if not, provide a UIColor
}

- (NSArray *)testDevices
{
	return [NSArray arrayWithObjects: ADMOB_SIMULATOR_ID, nil];
}

- (void)didReceiveAd:(AdMobView *)adView
{
	CCLOG(@"AdMob: Did receive ad");

	[self rotateBannerView:[self currentOrientation]];
	[self.view addSubview:adMobAd];

	[delegate adController:self didLoadAdMobAd:adView];
}

// Sent when an ad request failed to load an ad
- (void)didFailToReceiveAd:(AdMobView *)adView
{
	CCLOG(@"AdMob: Did fail to receive ad");
	[adMobAd removeFromSuperview];
	[adMobAd release];
	adMobAd = nil;

	[delegate adController:self didFailedToRecieveAdMobAd:adView];
}

#pragma mark -
#pragma mark Memory Management

- (void) dealloc
{
	if (adMobAd)
	{
		[adMobAd setDelegate:nil];
		[adMobAd removeFromSuperview];
		[adMobAd release];
		adMobAd = nil;
	}

	if (adBannerView)
	{
		[adBannerView setDelegate:nil];
		[adBannerView removeFromSuperview];
		[adBannerView release];
		adBannerView = nil;
	}

    [super dealloc];
}

@end

The usage is very simple, #import AdViewController.h in you Layer's .h and add the delegate protocol AdViewControllerDelegate

#import "AdViewController.h"

@interface Menu : CCLayer <AdViewControllerDelegate>
{
	AdViewController	*adController;
}

And in your layer's .m add this

- (void)onEnter
{
	[super onEnter];

	adController = [[AdViewController alloc] initWithMasterView:[[CCDirector sharedDirector] openGLView]];
	[adController setDelegate:self];

}

- (void)onExit
{
	//Completely remove the controller
	[adController setDelegate:nil];
	[adController release];
	adController = nil;

	[super onExit];
}

- (void)adController:(AdViewController*)controller didLoadiAd:(id)iadBanner;
{
	//Do something when the ad loads, like moving objects.
}

- (void)adController:(AdViewController*)controller didFailedToRecieveiAd:(id)iadBanner;
{
	//Do something when the ad fails to load, like moving objects.;
}

- (void)adController:(AdViewController*)controller didLoadAdMobAd:(AdMobView*)adMobBanner;
{
	//Do something when the ad loads, like moving objects.
}

- (void)adController:(AdViewController*)controller didFailedToRecieveAdMobAd:(AdMobView*)adMobBanner;
{
	//Do something when the ad fails to load, like moving objects.
}
훌 이분 용자인듯 0.0

//h파일


#import "cocos2d.h"


@interface SpritePosChange : CCScene {

}


-(void) SpritePosChange:(CCSprite*)mSprite : (int) xPos : (int) yPos;


@end




//m파일

#import "SpritePosChange.h"



@implementation SpritePosChange

-(id) init

{

if((self = [super init]))

{

}

return self;

}

-(void) SpritePosChange:(CCSprite*)mSprite : (int) xPos : (int) yPos

{

mSprite.anchorPoint = ccp(0,1);

mSprite.position = ccp(xPos,480-yPos);

}

-(void)dealloc

{

[super dealloc];

}


@end



//아주 간단한 클래스 입니다 ^^ 왕초보라서.~! 그냥 좌상단이 보통 0,0 인데  OpenGl의 기준점은 좌하단이 0,0으로 되어 있어서 
  디자이너들의 좌표 와 정반대로 찍혀 있어서 그냥 만들어 봤음. ^^

//

+ Recent posts