gpt4 book ai didi

iphone - 用于 iPhone 游戏开发的 Cocos2d 中的图层与场景

转载 作者:行者123 更新时间:2023-12-03 18:57:05 26 4
gpt4 key购买 nike

使用cocos2d进行iPhone游戏开发,我对Layer和Scene感到困惑。例如,我的简单游戏有几个“UI 页面”,如主菜单、高分、游戏板等。

那么我应该为每个“UI 页面”使用图层还是场景,为什么?

最佳答案

查看SpritesDemo.m/.h,看起来他们正在使用Layer,然后创建新场景,附加图层,然后替换导演上的场景

@interface SpriteDemo : Layer
@interface SpriteManual : SpriteDemo

代码然后执行以下操作:

-(void)nextCallback:(id)sender {
Scene *s = [Scene node];
[s add: [nextAction() node]];
[[Director sharedDirector] replaceScene s];
}

所以,简而言之,你的问题的答案是“两者”,你使用 Layer 来表示你的实际“UI 页面”,但你将 Layer 附加到一个新场景并替换 direct 中的当前场景。

关于iphone - 用于 iPhone 游戏开发的 Cocos2d 中的图层与场景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/614090/

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