为什么游戏在 libgdx 中运行缓慢? [英] why game is running slow in libgdx?

查看:19
本文介绍了为什么游戏在 libgdx 中运行缓慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Libgdx 中制作赛车游戏.我的游戏 apk 大小为 9.92 mb,我使用四个纹理打包器,总大小为 9.92 Mb.我的游戏在台式机上运行,​​但在 android 设备上运行速度非常慢.背后的原因是什么?

I am making racing game in Libgdx.My game apk size is 9.92 mb and I am using four texture packer of total size is 9.92 Mb. My game is running on desktop but its run on android device very slow. What is reason behind it?

推荐答案

我们在编程时忽略的漏洞很少.桌面处理器功能更强大,因此游戏可以在桌面上流畅运行,但在移动设备上可能会变慢.

There are few loopholes which we neglect while programming. Desktop processors are way more powerful so the game may run smoothly on Desktop but may slow on mobile Device.

为了获得最佳游戏流程,您应该遵循以下一些关键注意事项:

Here are some key notes which you should follow for optimum game flow:

  1. render 方法中没有 I/O 操作.
  2. 避免在渲染方法中创建对象.
  3. 必须重复使用对象(例如,如果您的游戏有 1000 个平台,但在当前屏幕上您只能显示 3 个,而不是让 1000 个对象生成 5 或 6 个并重复使用它们).您可以使用 LibGdx 提供的 Pool 类进行对象池化.
  4. 尝试仅加载必须在当前屏幕上显示的资源.

如果调用了垃圾收集器,请尝试检查您的 logcat.如果是这样,请尝试使用对象类的 finalize 方法来查找哪个类对象被作为垃圾收集并尝试对其进行改进.

Try to check your logcat if the Garbage collector is called. If so than try to use finalize method of object class to find which class object are collected as garbage and try to improve on it.

祝你好运.

这篇关于为什么游戏在 libgdx 中运行缓慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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