我已将几个 UIKit 项添加到我的图层、一个 UITableView 和一个 UITextField。
如何让这些项目在过渡期间与场景的其余部分一起制作动画?
我已经尝试通过 CCDirector 添加项目,
[[[CCDirector sharedDirector] openGLView] addSubview:tableView];
以及使用 CCUIViewWrapper 类。
无论哪种方式,cocos2d 项目都会转换,但 UIKit 项目会保留在屏幕上,不会随屏幕的其余部分一起动画。
HelloWorldLayer *scene = (HelloWorldLayer *)[HelloWorldLayer scene];
[[CCDirector sharedDirector] replaceScene:[CCTransitionZoomFlipX transitionWithDuration:0.5 scene:(CCScene *)scene]];
只是为了测试,我使用了此处显示的旋转按钮示例: http://www.cocos2d-iphone.org/forum/topic/6889 并将上面的 replaceScene 代码添加到按钮操作中。
如果您还向屏幕添加了一个 CCLabelTTF,您会注意到标签随着过渡而动画化,但 Button 却没有。
最佳答案
我在使用 UIWebView 时遇到了同样的问题,我不得不使用 UIView 动画来移动它们
[UIView animateWithDuration:1.0f animations:^{
//Animation
}completion:^(BOOL finished) {
if(finished){
//Completed
}
}];
不过,注意 UIView 动画 block 的动画速度与以下相比:
[[CCDirector sharedDirector] replaceScene:[CCTransitionZoomFlipX transitionWithDuration:0.5 scene:(CCScene *)scene]];
我还没有找到一个完美的解决方案,但我发现当我为 UIView 设置动画时,如果我在为它设置动画时淡出它,它会让它看起来更平滑
https://stackoverflow.com/questions/8379374/
相关文章:
continuous-integration - 自动构建 Access 2007 数据库
xml - HTML 到 XML,反之亦然,并在运行时从 UI - JAXB 使用模式进行验证?
asp.net-mvc - ASP.NET MVC 表单例份验证导致登录 url 被调用两次
macos - 从终端的钥匙串(keychain)中删除私钥
django - 如何更改方法 is_valid() 中的表单字段
ruby-on-rails-3 - 无法修改关联,因为源反射类通过 :has_many + rail
ruby-on-rails - Rails - I18n - 如何本地化 f.collection_