zho*_*shu 5 iphone cocoa-touch cocos2d-iphone
使用cocos2d进行iPhone游戏开发,我在Layer和Scene之间感到困惑.例如,我的简单游戏有几个"UI页面",如主菜单,高分,游戏板等.
那么我应该为每个"UI页面"使用Layer或Scene,为什么?
查看SpritesDemo.m/.h,看起来他们正在使用Layer,然后创建新场景,附加图层,然后替换director上的场景
@interface SpriteDemo : Layer
@interface SpriteManual : SpriteDemo
Run Code Online (Sandbox Code Playgroud)
然后代码执行以下操作:
-(void)nextCallback:(id)sender {
Scene *s = [Scene node];
[s add: [nextAction() node]];
[[Director sharedDirector] replaceScene s];
}
Run Code Online (Sandbox Code Playgroud)
所以,简而言之,你的问题的答案是“两者”,你使用 Layer 来表示你的实际“UI 页面”,但你将 Layer 附加到一个新场景并替换director中的当前场景。
| 归档时间: |
|
| 查看次数: |
7482 次 |
| 最近记录: |