首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >libgdx阿什利ecs框架-小对象组件与大对象组件

libgdx阿什利ecs框架-小对象组件与大对象组件
EN

Stack Overflow用户
提问于 2016-07-15 05:33:02
回答 1查看 723关注 0票数 0

在libGDX阿什利ecs框架中,我们需要将大型object拆分为Components。我想看看SpriteComponent的边缘是什么(Sprite仍然是一个大的object)到TextureComponentSizeComponentPositionComponentOriginComponentRotationComponentScaleComponent (或TransformComponent & SizeComponent)。

代码语言:javascript
复制
TextureComponent - @field: TextureRegion region
SizeComponent - @field: float width, float height
TransformComponent - @field: Vector2 position, Vector2 origin, Vector2 scale, float rotation

entity.add(texture);
entity.add(size);
entity.add(transform);

V.S

SpriteComponent - @field: Sprite sprite

entity.add(sprite);

or the combination of both

entity.add(texture);
entity.add(size);
entity.add(transform);
entity.add(sprite);

SpriteSystem - overrides the size and transform components
RenderingSystem - uses the texture, size, transform components to draw object

如果Transform & Size Component已经添加为Entity Components,您需要使用SpriteComponent吗?

我不确定在我的SpriteSystem上,这是否是正确的行为。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-15 13:45:45

在我看来,像阿什利这样的实体组件系统的目标是让系统处理游戏中实体的所有组件。假设您将SpriteComponent拆分为TextureComponentSizeComponentTransformComponent,您将实现TextureSystem还是SizeSystem?这些系统将遍历所有实体,如果它们有特定的组件,则执行某些逻辑,每个帧。也许你的具体游戏将改变大多数实体的大小或纹理的一个帧的基础上,但对我来说,这是不可能的,你的性能将受到这种设计。在阿什利和其他ECS中显示的例子给出了一个组件可能是什么:输入,位置,速度,渲染.就目前而言,最好的办法就是坚持下去。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38388481

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档