适用于多关卡/屏幕游戏的适当的Scenekit体系结构 [英] Proper scenekit architecture for multi level/screen games

查看:106
本文介绍了适用于多关卡/屏幕游戏的适当的Scenekit体系结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Scenekit的新手,所以当我开始我的第一个项目时,我注意到它与spritekit略有不同.尽管不理想,但我过去在spritekit中使用了1个gameviewcontroller和1个gamecene来编写我的整个游戏. (是的,其中包括菜单,游戏/关卡,设置等...)

I'm new to scenekit, so when I started my first project I noticed it's slightly different from spritekit. Although not ideal, I used to use 1 gameviewcontroller and 1 gamescene in spritekit to code my entire game. (YES, this includes a menu, game/levels, settings, etc...)

我现在想知道自从我正在使用SCNScenes(它们是从viewcontroller加载的)以来,我不希望我的1个view controller充满代码.布置游戏的最佳方法是什么?每个SCNScene我应该有1个ViewController吗? (切换到其他视图控制器用于:主菜单,游戏级别1,游戏级别2,游戏级别3,游戏结束,设置等.)

I'm now wondering since I'm using SCNScenes (which are just loaded from the viewcontroller), I do not want my 1 view controller to be swamped with code. What is the best way to layout a game? Should i have 1 viewcontroller per SCNScene? (switching to a different view controller for: main menu, game level 1, game level 2, game level 3, game over, settings, etc..)

这可能不是措辞完美,但我感谢您的帮助!

This may not have been worded perfectly, but i appreciate the help!

爱丹

推荐答案

我对具有多个级别,地图和交互式游戏菜单的游戏的典型布局:

My typical layout for games with multiple levels, maps, interactive game play menus:

MainMenuVC SelectLevelVC,SelectMapVC等.

MainMenuVC SelectLevelVC, SelectMapVC, etc.

GameVC(平视显示器,得分,游戏菜单),DefenseVC(类似叠加层,选择武器)

GameVC (Hud, score, in-game menus), DefenseVC (like an overlay, choose weapon)

EndWaveVC,EndGameVC

EndWaveVC, EndGameVC

GameControl()-计时器,数组迭代,检查wave完成,nextWave,清理等.

GameControl() - Timers, array iteration, check wave completed, nextWave, cleanup, etc.

数据-VC和游戏对象之间共享的数据的共享实例(数组,开关)

Data - shared instance (arrays, switches) for data shared between VC’s and game objects

BaseObjects,例如(防御,爆炸,声音,移动,定向)

BaseObjects such as (defenses, explosions, sounds, movement, targeting)

GameNodes(所有节点的创建和存储,模型加载,粒子加载,摄影机,灯光)

GameNodes (all node creation and storage, model loading, particle loading, camera, lights)

我经过许多次迭代才降落在这里.需要权衡取舍,但是通过将VC与数据和Scenekit分开,可以保持整洁.必要时,它还增强了仅在少数几个地方执行线程和计时器的能力.

I landed here though many iterations. There are some tradeoffs, but by separating VC’s from data and scenekit things can stay pretty clean. It also enhances the ability to do threading and timers in only a few places when needed.

数据的sharedInstance允许游戏对象遍历数组以查找目标和对象,例如试图找到敌人的防御,反之亦然.当游戏对象需要开始互相交谈时,通常是在游戏设计开始偏离轨道的地方.因此,我通过GameControl中的计时器来循环循环,共享数据,并保持数据的整洁.由于我在一个地方执行循环,因此可以避免在更新其他对象时踩踏它们,并可以对定时和控制FPS进行一些清晰的测量.

The sharedInstance of Data allows game objects to iterate through arrays to find targets and objects, such as a defense trying to find an enemy and vice versa. When game objects need to start talking to each other, this is usually where game design starts going off the tracks. So, I iterate loops via timers in GameControl, sharing Data, and that keeps it pretty clean. Since I’m doing loops in one place, I can avoid trampling other objects while they are updating and also get some clean measurements of timing and control FPS.

希望有帮助.

这篇关于适用于多关卡/屏幕游戏的适当的Scenekit体系结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆