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

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

问题描述

我用我的游戏的java + AndEngine。

在游戏过程中我有一些结冰,我找的资料,并发现了一些步骤,如何优化游戏性能:

  1. 避免GC(垃圾收集器)是 称为在游戏中的主要作用:
    一)在玩游戏时不创建对象;
    B)不要产生不必要的对象;
  2. 优化code,重复很 常

我跟着这些步骤,但从来没有少我在游戏过程中有一定的冻结。

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

解决方案
  1. 降低纹理尺寸。
  2. 减少纹理开关(又名尝试使用spritesheets,从而使质地需要改变尽可能少)
  3. 使用低质量的纹理(RGBA4444或RGB565,而不是RGBA8888)..
  4. 呼叫setIgnoreUpdate那里的实体并不需要更新。
  5. <一个href="http://www.andengine.org/forums/updates/spritebatch-2x-performance-improvement-anyone-t3613-10.html">Use SpriteBatches如果可能的话。

供参考: AndEngine的下一个版本(来临的12月中旬)体育GLES2让你有更多的可能性,以改善与自定义着色器和实体的表现。

此外,它会执行,而不是阻止启动管道(onLoadEngine / onLoadResources / onLoadScene /的onLoadComplete)的GL-线程的第一帧上,在UI线程(直接的onCreate)。

此外,它可以让你轻松卸载管道的阶段成线,不破坏管道作为一个整体。会有一个非常简单的实施BaseGameActivity的子类,示出了确定的ProgressDialog而流水线的阶段被执行。实体将在弹出因为它们连接到现场。

在一般,这意味着,实际loadingtimes降低,而且更重要的是,毡loadingtimes是reducedsignificantly!创建一个加载屏幕是很轻松,而不是痛苦以前。

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. Avoid GC (garbage collector) to be called in main action in the game:
    a)don't create objects while gaming;
    b)don't create unnecessary objects;
  2. Optimize code that repeats very often

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. Reduce texture sizes.
  2. Reduce texture switches (aka try to use spritesheets, so that the texture needs to be changed as few as possible)
  3. Use lower quality textures (RGBA4444 or RGB565 instead of RGBA8888)..
  4. Call setIgnoreUpdate where the entity doesn't need updates.
  5. Use SpriteBatches if possible.

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.

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).

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天全站免登陆