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

查看:127
本文介绍了为什么游戏在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. 渲染方法中没有I/O操作.
  2. 避免在渲染方法中创建对象.
  3. 必须重用对象(例如,如果您的游戏有1000个平台,但在当前屏幕上只能显示3个,而不是使1000个对象变成5个或6个并重用它们).您可以使用LibGdx提供的Pool类进行对象池化.
  4. 尝试仅加载那些需要在当前屏幕上显示的资产.

尝试检查您的日志猫是否调用了垃圾收集器.如果是这样,则尝试使用对象类的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天全站免登陆