在 Libgdx 中实现简单运动模糊的意外结果

Unexpected results implementing simple motion blur in Libgdx(在 Libgdx 中实现简单运动模糊的意外结果)

本文介绍了在 Libgdx 中实现简单运动模糊的意外结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在所附的两张图片中,libgdx 的桌面截图按预期运行.不幸的是,我的 Galaxy Nexus 的屏幕截图不如预期.我正在尝试创建一个简单的运动模糊或轨迹效果.

In the two attached pictures, the desktop screenshot of libgdx functions as expected. The screenshot from my Galaxy Nexus is unfortunately not as expected. I am attempting to create a simple motion blur or trail effect.

在我的桌面上按预期进行渲染.

Rendering as I expected on my desktop.

在我的 Galaxy Nexus 上未按预期呈现.

Not rendering as I expected on my Galaxy nexus.

在渲染过程中,圆形纹理在for循环中绘制,效果是通过使用在圆形之前绘制的0、0、0、0.1f的RGBA的像素图来实现的.

The circle textures are drawn in a for loop during rendering and the effect is achieved with a pixmap using the RGBA of 0, 0, 0, 0.1f that is drawn before the circles.

screenClearSprite 创建

Pixmap screenClearPixmap = new Pixmap(256, 256, Format.RGBA8888);
screenClearPixmap.setColor(Color.rgba8888(0, 0, 0, 0.1f));
screenClearPixmap.fillRectangle(0, 0, 256, 256);
screenClearTexture = new Texture(screenClearPixmap);
screenClearSprite = new Sprite(screenClearTexture);
screenClearSprite.setSize(screenWidth, screenHeight);
screenClearPixmap.dispose();

渲染

batch.begin();
font.draw(batch, "fps:" + Gdx.graphics.getFramesPerSecond(), 0, 20);
screenClearSprite.draw(batch);
for (int i = 0; i < circleBodies.size(); i++) {
    tempPos = circleBodies.get(i).getPosition();
    batch.draw(circleTexture, (tempPos.x * SCALE) + screenWidthHalf
            - circleSizeHalf, (tempPos.y * SCALE) + screenHeightHalf
            - circleSizeHalf);
}
batch.end();

那么,我做错了什么?也许有更好的方法来获得运动的运动模糊"效果?

So, what did I do wrong? Perhaps there is a better way to get the 'motion blur' effect of movement?

推荐答案

也许有更好的方法来获得运动模糊"效果运动?

Perhaps there is a better way to get the 'motion blur' effect of movement?

为了在我的游戏中制作运动模糊,我使用了另一种方法粒子效果",它对我非常有效,而且我没有 Android/桌面问题或不同的 Android 设备

in order to make motion blur in my game i use another approch "The particle effect" it works realy fine with me and i didn't have Android/Desktop problems or with different android devices

您所要做的就是使用 Libgdx 的粒子效果编辑器"并制作您的效果,然后将其加载到您的项目中,最后在您绘制对象的同一位置绘制它(并且也绘制您的对象)

all you have to do is to use "Particle Effect Editor" of Libgdx and make your effect then load it in your project finally draw it at the same position you draw your object (and alos draw your object)

使用 Particle Editor 制作正确效果文件的提示:

Tips to make the right effect file with Paticle Editor :

  • 在粒子效果中设置(使用)您想要使其运动模糊的对象的相同图像

  • set (use) the same image of the object that you want to blur it motion in the particle effect

尝试限制count:允许的最大粒子数

try to limit the count : the max number of particle allowed

禁用速度"和角度"参数

Disable the "velocity" and "Angle" parameter

粒子效果有助于做运动效果希望这会对某人有所帮助!

Particle effect help to do motion effect Hope this will help someone !

这篇关于在 Libgdx 中实现简单运动模糊的意外结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在 Libgdx 中实现简单运动模糊的意外结果

基础教程推荐