gpt4 book ai didi

iphone - Cocos2D Director暂停/恢复问题

转载 作者:行者123 更新时间:2023-12-03 19:00:57 24 4
gpt4 key购买 nike

我正在尝试在 cocos2D 中播放 .gif 动画。为此,我使用库 glgif。现在,为了显示动画,我暂停了Director,添加了一个 subview 来显示动画,动画完成后我将恢复Director。但是,我无法恢复Director的状态,它显示为空白。所以我在没有暂停和恢复这个Director的情况下尝试了这个,但它仍然不起作用。我还尝试在动画之前分离director并在之后将其添加回来,即使这样也不起作用。

那么有没有办法在应用程序中暂停/暂停Director并正确恢复回来?

谢谢。

代码示例:

[[Director sharedDirector] pause]; 
[[Director sharedDirector] detach];
AppDelegate *del = [[UIApplication sharedApplication] delegate];
[del.window addSubview:del.viewController.view];
[del.window makeKeyAndVisible]; // this is code to call glgif class and start anim.
//code to resume the director
AppDelegate *del = [[UIApplication sharedApplication] delegate];
[[Director sharedDirector] resume];
[[Director sharedDirector] attachInView:del.window];
MScene *m = [MScene node];
[[Director sharedDirector] replaceScene:m];

最佳答案

如果它是一个简单的覆盖,只需暂停并直接执行 UIKit 调用即可。像这样:

- (void)playerChanged
{
[[CCDirector sharedDirector] pause];
UIAlertView *alert = [[[UIAlertView alloc]
initWithTitle:NSLocalizedString(@"CHANGEPLAYER", nil)
message:nil
delegate:self
cancelButtonTitle:nil
otherButtonTitles:NSLocalizedString(@"OK", nil),
nil
] autorelease];
[alert show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
(void)alertView;
(void)buttonIndex;

[[CCDirector sharedDirector] resume];
}

如果你真的要接管整个窗口,那就彻底处置它

[[CCDirector sharedDirector] end];

并在返回时重做初始化并调用 runWithScene 。分离/附加舞蹈似乎效果不佳或不一致。

关于iphone - Cocos2D Director暂停/恢复问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1921658/

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