适用于多级/屏幕游戏的适当场景套件架构 [英] Proper scenekit architecture for multi level/screen games

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

问题描述

我是 Scenekit 的新手,所以当我开始我的第一个项目时,我注意到它与 spritekit 略有不同.虽然不理想,但我曾经在 spritekit 中使用 1 个游戏视图控制器和 1 个游戏场景来编写我的整个游戏.(是的,这包括菜单、游戏/关卡、设置等...)

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(刚刚从视图控制器加载),我不希望我的 1 视图控制器被代码淹没.什么是布局游戏的最佳方式?每个 SCNScene 应该有 1 个视图控制器吗?(切换到不同的视图控制器:主菜单、游戏级别 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:

主菜单VCSelectLevelVC、SelectMapVC 等

MainMenuVC SelectLevelVC, SelectMapVC, etc.

GameVC(Hud、得分、游戏内菜单)、DefenseVC(如叠加层,选择武器)

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

EndWaveVC、EndGameVC

EndWaveVC, EndGameVC

GameControl() - 定时器、数组迭代、检查波完成、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 such as (defenses, explosions, sounds, movement, targeting)

GameNodes(所有节点创建和存储、模型加载、粒子加载、相机、灯光)

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

经过多次迭代,我还是来到了这里.有一些权衡,但通过将 VC 与数据和场景套件分开,事情可以保持非常干净.它还增强了在需要时仅在少数地方执行线程和计时器的能力.

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.

希望有所帮助.

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

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