私はCocos2dプロジェクトを持っており、アプリ全体で一定のバックグラウンドが必要です。そのデリゲートのapplicationDidFinishLaunching
方法で、私は次の行を置き換えました:
glViewのpixelFormatをからkEAGLColorFormatRGB565
に変更しましたkEAGLColorFormatRGBA8
。その変更を行うと、glViewは透明になり、透けて見えますが、fpsは劇的に低下します。その変更を行わないと、ビューは透明になりませんが、fpsの大幅な低下は見られません。59.0〜60.0から約35.0〜42.0へのfpsの大幅な低下について話しています。
ビューを透明にするために、上のaddSubview行のすぐ下にあるこのコードを使用しています。
director.openGLView.opaque = NO;
applicationDidFinishLaunchingメソッド全体は次のようになります。
- (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:kEAGLColorFormatRGBA8 // kEAGLColorFormatRGBA8
depthFormat:0 // GL_DEPTH_COMPONENT16_OES
];
// attach the openglView to the director
[director setOpenGLView:glView];
glView.opaque = NO;
// // 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
[viewController setView:glView];
//Required in iOS6, recommended in 4 and 5
[window setRootViewController:viewController];
// make the View Controller a child of the main window, needed for iOS 4 and 5
[window addSubview: viewController.view];
[window makeKeyAndVisible];
// 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: [Intro scene]];
}
なぜこれが起こっているのかについてのアイデアはありますか?必要に応じて、より多くのコードを提供できます。
私が行ったもう1つのコード変更について言及するのを忘れました。CCDirector.msetGLDefaultValues
で、この行を次のように変更しました。
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
これに:
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);