3

我想在我的游戏中使用 artemis ( https://github.com/junkdog/artemis-odb )。

最近我读到了 Glenn Fiedler 的游戏循环: http: //gafferongames.com/game-physics/fix-your-timestep/

所以提到的游戏循环有两个部分,artemis world.process(); 会发生。集成部分和渲染部分。

任何想法我如何用阿尔忒弥斯完成这样的事情。

while(!quit) {
    .....
    while (accumulator >= dt) {
       world.process("only EntitySystems of group1 or with Components X (INTEGRATE STUFF)");
       ....
    }
    ....
    world.process("only EntitySystems of group2 or with Components Y (RENDER STUFF)");
}

artemis 支持这种游戏循环吗?

我现在想到的唯一解决方案是:

设置一个全局静态标志,指示其是集成还是渲染过程,然后EntitySystem.process(Entity e)在设置错误标志时退出所有方法。像这样:

@Override
protected void process(Entity e) {
    if(GLOBAL.RENDER_TIME) {
        return; // exit cause, this entity should only be processed when it is INTEGRATE TIME
    }   
}

问题在于,由于实体不处理任何内容,因此不需要对许多实体进行迭代。

我正在考虑拥有 2 个Worlds,但我认为我不能轻松地在 之间共享相同的 Component 实例Worlds,尤其是当它们是池对象时。

知道如何结合 artemis-odb + Glenn Fiedler 游戏循环吗?

编辑:刚刚发现我可以setEnabled()用来禁用和启用EntitySystems. 现在就可以了。

4

1 回答 1

2

https://github.com/junkdog/artemis-odb/wiki/InvocationStrategy

这就是我一直在寻找的

这就是我实现它的方式: https ://github.com/TomGrill/logic-render-game-loop

于 2015-10-16T15:48:59.513 回答