こんにちは、cocos 2D は初めてです。cocos2D v 2.x を使用し、cocos2D テンプレートからアプリを作成しました。シーンに 5 つの CCSprite を追加したところ、数分後に fps が徐々に 10.0 を下回り、アプリが lldb エラーでクラッシュします。初期設定とその他の情報のための私のコードは次のとおりです。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
window_ = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
CCGLView *glView = [CCGLView viewWithFrame:[window_ bounds]
pixelFormat:kEAGLColorFormatRGB565 //kEAGLColorFormatRGBA8
depthFormat:0 //GL_DEPTH_COMPONENT24_OES
preserveBackbuffer:NO
sharegroup:nil
multiSampling:NO
numberOfSamples:0];
[glView setMultipleTouchEnabled:YES];
director_ = (CCDirectorIOS*) [CCDirector sharedDirector];
director_.wantsFullScreenLayout = YES;
[director_ setDisplayStats:YES];
[director_ setAnimationInterval:1.0/60];
[director_ setView:glView];
[director_ setDelegate:self];
[director_ setProjection:kCCDirectorProjection2D];
if( ! [director_ enableRetinaDisplay:YES] )
CCLOG(@"Retina Display Not supported");
// 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];
// If the 1st suffix is not found and if fallback is enabled then fallback suffixes are going to searched. If none is found, it will try with the name without suffix.
// On iPad HD : "-ipadhd", "-ipad", "-hd"
// On iPad : "-ipad", "-hd"
// On iPhone HD: "-hd"
CCFileUtils *sharedFileUtils = [CCFileUtils sharedFileUtils];
[sharedFileUtils setEnableFallbackSuffixes:NO]; // Default: NO. No fallback suffixes are going to be used
[sharedFileUtils setiPhoneRetinaDisplaySuffix:@"-hd"]; // Default on iPhone RetinaDisplay is "-hd"
[sharedFileUtils setiPadSuffix:@"-ipad"]; // Default on iPad is "ipad"
[sharedFileUtils setiPadRetinaDisplaySuffix:@"-ipadhd"]; // Default on iPad RetinaDisplay is "-ipadhd"
// Assume that PVR images have premultiplied alpha
[CCTexture2D PVRImagesHavePremultipliedAlpha:YES];
// and add the scene to the stack. The director will run it when it automatically when the view is displayed.
[director_ pushScene: [IntroLayer scene]];
// Create a Navigation Controller with the Director
navController_ = [[UINavigationController alloc] initWithRootViewController:director_];
navController_.navigationBarHidden = YES;
// set the Navigation Controller as the root view controller
// [window_ addSubview:navController_.view]; // Generates flicker.
[window_ setRootViewController:navController_];
// make main window visible
[window_ makeKeyAndVisible];
return YES;
}
init メソッドの HeloworldLayer.m のコード
- (id)init {
if ((self=[super init])) {
winSize = [CCDirector sharedDirector].winSize;
CCSprite * background =[CCSprite spriteWithFile:@"Bg.png" rect:CGRectMake(0, 0, 1024, 768)];
background.position=ccp(winSize.width/2, winSize.height/2);
[self addChild:background];
CCSprite *bgstand=[CCSprite spriteWithFile:@"back_side.png"];
bgstand.position=ccp(winSize.width/2, winSize.height/2-150);
[self addChild:bgstand];
CCSprite *wheel=[CCSprite spriteWithFile:@"wheel.png"];
wheel.position=ccp(winSize.width/2, winSize.height/2+55);
[self addChild:wheel];
CCSprite *fgstand=[CCSprite spriteWithFile:@"front_side.png"];
fgstand.position=ccp(winSize.width/2, winSize.height/2-150);
[self addChild:fgstand];
}
return self;
}
コードを実行すると、この種のログが表示されました
2013-05-23 17:04:06.045 Box2Dtry[2333:c07] cocos2d: OS version: 6.1 (0x06010000)
2013-05-23 17:04:06.046 Box2Dtry[2333:c07] cocos2d: GL_VENDOR: Apple Computer, Inc.
2013-05-23 17:04:06.046 Box2Dtry[2333:c07] cocos2d: GL_RENDERER: Apple Software Renderer
2013-05-23 17:04:06.047 Box2Dtry[2333:c07] cocos2d: GL_VERSION: OpenGL ES 2.0 APPLE
2013-05-23 17:04:06.047 Box2Dtry[2333:c07] cocos2d: GL_MAX_TEXTURE_SIZE: 4096
2013-05-23 17:04:06.048 Box2Dtry[2333:c07] cocos2d: GL_MAX_TEXTURE_UNITS: 8
2013-05-23 17:04:06.048 Box2Dtry[2333:c07] cocos2d: GL_MAX_SAMPLES: 4
2013-05-23 17:04:06.048 Box2Dtry[2333:c07] cocos2d: GL supports PVRTC: YES
2013-05-23 17:04:06.049 Box2Dtry[2333:c07] cocos2d: GL supports BGRA8888 textures: YES
2013-05-23 17:04:06.049 Box2Dtry[2333:c07] cocos2d: GL supports NPOT textures: YES
2013-05-23 17:04:06.049 Box2Dtry[2333:c07] cocos2d: GL supports discard_framebuffer: YES
2013-05-23 17:04:06.050 Box2Dtry[2333:c07] cocos2d: GL supports shareable VAO: NO
2013-05-23 17:04:06.050 Box2Dtry[2333:c07] cocos2d: compiled with Profiling Support: NO
2013-05-23 17:04:06.051 Box2Dtry[2333:c07] cocos2d: **** WARNING **** CC_ENABLE_GL_STATE_CACHE is disabled. To improve performance, enable it by editing ccConfig.h
2013-05-23 17:04:06.098 Box2Dtry[2333:c07] cocos2d: cocos2d v2.0.0
2013-05-23 17:04:06.098 Box2Dtry[2333:c07] cocos2d: Using Director Type:CCDirectorDisplayLink
2013-05-23 17:04:06.114 Box2Dtry[2333:c07] cocos2d: animation started with frame interval: 60.00
2013-05-23 17:04:06.115 Box2Dtry[2333:c07] cocos2d: surface size: 2048x1536
2013-05-23 17:04:07.432 Box2Dtry[2333:c07] cocos2d: CCTexture2D: Using RGB565 texture since image has no alpha