일반적으로 coco2d OpenGL보기는 appdelegate에서 시작됩니다.viewcontroller에서 coco2d OpenGL보기 시작
방법 항목 : 의 ViewController에서 출시 : AppDelegate에에서 luanching
- (void) applicationDidFinishLaunching:(UIApplication*)application
{
// Init the window
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// 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
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
//
// 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
//
//
EAGLView *glView = [EAGLView viewWithFrame:[window bounds]
pixelFormat:kEAGLColorFormatRGB565 // kEAGLColorFormatRGBA8
depthFormat:0 // GL_DEPTH_COMPONENT16_OES
];
// attach the openglView to the director
[director setOpenGLView:glView];
하지만 난이
방법 2를했던 내의 ViewController의 viewDidLoad에 기능 내부, 그래서의 ViewController 에서 OpenGL을보기를 시작할 수 필요 - (void) viewDidLoad {
[super viewDidLoad];
self.view.frame = CGRectMake(0, 0, 320, 480);
// Create an CCGLView with a RGB565 color buffer, and a depth buffer of 0-bits
CCGLView *glView = [CCGLView viewWithFrame:CGRectMake(0,0,320,480)
pixelFormat:kEAGLColorFormatRGB565 //kEAGLColorFormatRGBA8
depthFormat:0 //GL_DEPTH_COMPONENT24_OES
preserveBackbuffer:NO
sharegroup:nil
multiSampling:NO
numberOfSamples:0];
director_ = (CCDirectorIOS*) [CCDirector sharedDirector];
director_.wantsFullScreenLayout = YES;
// Display FSP and SPF
[director_ setDisplayStats:YES];
// set FPS at 60
[director_ setAnimationInterval:1.0/60];
// attach the openglView to the director
[director_ setView:glView];
// for rotation and other messages
[director_ setDelegate:self];
// 2D projection
[director_ setProjection:kCCDirectorProjection2D];
// Run the intro Scene
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
// and add the scene to the stack. The director will run it when it automatically when the view is displayed.
[director_ pushScene: [helloworld scene]];
metho d2가 작동하지 않습니다. 어떤 장면도 보지 못했습니다. 아무 것도 나타나지 않습니다. 그래서 OpenController를 ViewController에서 현재 상태로 만드는 방법이 문제가됩니까?