gpt4 book ai didi

objective-c - 将 cocos2d 场景添加到 UIViewController

转载 作者:太空狗 更新时间:2023-10-30 04:02:51 25 4
gpt4 key购买 nike

我使用以下代码将 cocos2d 场景添加到 View Controller

- (void)viewDidLoad {
self.view = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,480)];


if( ! [CCDirector setDirectorType:CCDirectorTypeDisplayLink] )
[CCDirector setDirectorType:CCDirectorTypeDefault];

[[CCDirector sharedDirector] setPixelFormat:kPixelFormatRGBA8888];

[CCTexture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888];


[[CCDirector sharedDirector] setDeviceOrientation:kCCDeviceOrientationPortrait];
[[CCDirector sharedDirector] setAnimationInterval:1.0/60];

[[CCDirector sharedDirector] attachInView:self.view];
///adding HelloWorld scene to the view...
[[CCDirector sharedDirector] runWithScene: [HelloWorld scene]];
[super viewDidLoad];
}

现在我需要设置 self.view 的 alpha 值....所以我做到了..

-(void)displaySharePage
{
self.view.alpha=0;

}

但它崩溃了......不知道为什么......我收到消息......

'A Director was alloced. setDirectorType must be the first call to Director'

谁能帮忙.....提前谢谢..

最佳答案

关于objective-c - 将 cocos2d 场景添加到 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3433720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com