GKComponentSystem

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





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值