2011-06-21 7 views
1

私はあなたがのplayButtonをクリックしますと、それはその本体のコード下記の持つメソッドを呼び出します メソッドを呼び出してcocos2dアニメーションを停止する方法は?

-(void) mainMenu { 
//BackgroundImage 
//Play Button 
//Help Button 
} 
として2ボタン、遊び、助けと1つのバックグラウンドを持っています。

-(void)Play { 

    // Try to use CADisplayLink director 
// if it fails (SDK < 3.1) use the default director 


if(! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink]) 
[CCDirector setDirectorType:kCCDirectorTypeDefault]; 

CCDirector *director = [CCDirector sharedDirector]; 

// Init the View Controller 

// 
// Create the EAGLView manually 
// 1. Create a RGB565 format. Alternative: RGBA8 
// 2. depth format of 0 bit. Use 16 or 24 bit for 3d effects, like CCPageTurnTransition 
// 
// 
CGRect rect = CGRectMake(0, 0, 320, 480); 

EAGLView *glView = [EAGLView viewWithFrame:rect 
pixelFormat:kEAGLColorFormatRGB565 // kEAGLColorFormatRGBA8 
depthFormat:0      // GL_DEPTH_COMPONENT16_OES 
]; 

// attach the openglView to the director 
[director setOpenGLView:glView]; 

// // Enables High Res mode (Retina Display) on iPhone 4 and maintains low  res  on all other devices 
// if(! [director enableRetinaDisplay:YES]) 
//  CCLOG(@"Retina Display Not supported"); 

// 
// VERY IMPORTANT: 
// If the rotation is going to be controlled by a UIViewController 
// then the device orientation should be "Portrait". 
// 
// IMPORTANT: 
// By default, this template only supports Landscape orientations. 
// Edit the RootViewController.m file to edit the supported orientations. 
// 
/* 
#if GAME_AUTOROTATION == kGameAutorotationUIViewController 
[director setDeviceOrientation:kCCDeviceOrientationPortrait]; 
#else 
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft]; 
#endif 
*/ 

[director setAnimationInterval:1.0/60]; 
[director setDisplayFPS:YES]; 


// make the OpenGLView a child of the view controller 
[self.view addSubview:glView]; 

// Default texture format for PNG/BMP/TIFF/JPEG/GIF images 
// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565 
// You can change anytime. 
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888]; 

// Removes the startup flicker 
//[self removeStartupFlicker]; 

// Run the intro Scene 
//[[CCDirector sharedDirector] runWithScene: [HelloWorldScene node]]; 

[[CCDirector sharedDirector] runWithScene: [PongLayer node]]; 
//[[CCDirector sharedDirector] replaceScene:[[[PongLayer alloc] init] autorelease]]; 
} 

今すぐゲーム中に私はそのプレイヤーは再びゲームを開始する必要があり、 はどのように私はアニメーションを停止することができ、バックはmainMenuの

答えて

0

あなたのメインメニューに行くので、バックのMainMenu画面を呼び出したい、それがのUIViewControllerでありますココスのオブジェクトではなく?あなたが正しく何をしているのか理解していて、DirectorのglViewをPlayでセットアップしてから、Directorを[[CCDirector sharedDirector] end]で終了し、親からglView([glView removeFromSuperView])を削除することができます。

プログラムでglViewを 'self'のサブビューとして追加しているので、メニューがまだglViewの下にあるとします。これが助けてくれたらと思っています。

関連する問題