GKComponentSystem
来源:互联网 发布:查泰莱夫人的情人 知乎 编辑:程序博客网 时间:2024/06/05 18:50
GKComponentSystem
管理指定类的所有组件对象定期更新消息。
概括
在一个组件/实体设计方式的游戏中,GKComponentSystem对象管理周期性更新的组件,使用组件系统为特定类的所有组件执行每个帧逻辑,而不需要遍历游戏的对象层次结构来发送更新消息。
每个GKComponentSystem对象都会管理特定GKComponent的子类,可以使用initWithComponentClass: 来创建特定组件Class实例。然后注册你需要的组件通过他们的实体,可以使用addComponent: 或者addComponentWithEntity: 方法。最后GKComponentSystem就会更新你所有注册了的组件实例所发来的消息。
组件中最重要的消息就是updateWithDeltaTime: 方法,调用游戏中update/render loop相关的方法,例如Spritekit中的update:方法或SceneKit中的renderer: updateAtTime:方法,或基于CADisplayLink的timer自定义一个渲染器,GKComponentSystem会通过updateWithDeltaTime: 执行所有GKComponent子类对象中的消息,从而调用每一帧的逻辑。
Topics
创建组件系统(Creating a Component System)
- initWithComponentClass:
创建特定组件类型的组件系统。
管理组件数组(Managing a List of Components)
componentClass
所管理组件的类型。
components
组件数组。
- addComponent:
添加一个组件实例到系统中。
- addComponentWithEntity:
从一个特定实体实例中添加其组件到系统中。
- removeComponent:
从系统中删除一个特定的组件。
- removeComponentWithEntity:
从系统中删除一个实体所拥有的所有组件。
定时更新(Performing Periodic Updates)
- updateWithDeltaTime:
使系统中所有的组件进行更新。
用下标语法访问组件(Accessing Components With Subscript Syntax)
- objectAtIndexedSubscript:
通过下标返回相对应的组件实例。
实例方法(Instance Methods)
- classForGenericArgumentAtIndex:
通过下标返回指定组件的类型。
关系
继承
NSObject
默认遵守
NSFastEnumeration
- GKComponentSystem
- AJAX(四)--JSON信息的处理
- Phoenix4.5适配CDH5.4
- ORACLE普通表转换成自动分区表
- 上海校区设计学院学员作品汇报展 2017年7月17号,传智播客上海校区设计学院组织了一期“学员作品展示”活动,一方面是为了检验学员所学成果,另一方面也让在校学生更好的了解设计学院。
- 【SqlServer】 数据库备份及其还原
- GKComponentSystem
- 有用的Java程序片段
- 常用手机尺寸以及分辨率
- LinuxStudyNote(8)-Linux常用命令(2)-文件处理命令(3)-切换工作目录命令cd
- AndroidStudio通用混淆配置文件
- 钓鱼网站:网络诈骗主要的劫财暗道
- Python连接数据库
- 实际项目中遇到的一些小问题
- 直方图变换