AndEngine游戏优化 [英] Optimization of AndEngine game

查看:27
本文介绍了AndEngine游戏优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的游戏中使用 java + AndEngine.

I am using java + AndEngine in my game.

在游戏过程中我有一些卡顿,我查找了信息并找到了一些如何优化游戏性能的步骤:

During the game i have some freezes, i looked for the information and found some steps how to optimize game performance:

  1. 避免 GC(垃圾收集器)成为在游戏的主要动作中调用:
    a)不要在游戏时创建对象;
    b) 不要创建不必要的对象;
  2. 优化重复非常多的代码经常

我遵循了这些步骤,但在游戏过程中我总是卡住.

I followed these steps, but never the less i have some freezes during the gameplay.

现在我正在游戏开始之前创建和加载所有纹理并且不卸载它们,这是一个坏主意吗?如何优化游戏进程?也许我必须在主要活动之前释放所有可能的内存,然后在每个级别之后重新加载它们?

Now i am creating and loading all of the textures before the game started and don't unload them, is it a bad idea ? How can i optimize the game proccess ? Maybe i have to make free all of the possible memory before main activity and then reload them after each level ?

推荐答案

  1. 减小纹理尺寸.
  2. 减少纹理切换(也就是尝试使用 spritesheets,以便尽可能少地更改纹理)
  3. 使用较低质量的纹理(RGBA4444 或 RGB565 而不是 RGBA8888).
  4. 在实体不需要更新的地方调用 setIgnoreUpdate.
  5. 尽可能使用 SpriteBatches.莉>

仅供参考:AndEngine 的下一个版本(将于 12 月中旬推出)支持 GLES2,因此您可以通过自定义着色器和实体来提高性能.

FYI: The next version of AndEngine (coming mid december) sports GLES2 so you have a lot more possibilities to improve performance with custom Shaders and Entities.

它还会在 GL-Thread 的第一帧上执行启动管道(onLoadEngine/onLoadResources/onLoadScene/onLoadComplete),而不是在 UI-Thread 上(直接在 onCreate 中进行阻塞).

Also it will execute the startup pipeline (onLoadEngine/onLoadResources/onLoadScene/onLoadComplete) on the first frame of the GL-Thread, instead of blocking, on the UI-Thread (directly in onCreate).

此外,它允许您轻松地将管道的各个阶段卸载到线程中,而不会破坏整个管道.将有一个非常简单的实现 BaseGameActivity 的子类,它在管道的各个阶段执行时显示一个确定的 ProgressDialog.实体将在它们附加到场景时弹出.

Also it allows you to easily offload the stages of the pipeline into Threads, without breaking the pipeline as a whole. There will be a very simple to implement subclass of BaseGameActivity that shows a determinate ProgressDialog while the stages of the pipeline are executed. Entities will pop in the as they are attached to the scene.

总的来说,这意味着实际加载时间减少了,更重要的是,毛毡加载时间显着减少了!与之前的痛苦相比,创建加载屏幕非常简单.

In general this means, the actual loadingtimes are reduced, and more importantly, the felt loadingtimes are reducedsignificantly! Creating a loading-screen is trivially easy, as opposed to the pain it was before.

这篇关于AndEngine游戏优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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