LibGDX:过滤缩放的TextureRegion [英] LibGDX: Filtering a scaled TextureRegion

查看:228
本文介绍了LibGDX:过滤缩放的TextureRegion的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个具有不同纹理的对象用于不同的状态,因此我使用TexturePacker制作的 TextureAtlas ,并调整 TextureRegion 我需要的地方。我必须调整大小,因为我不仅要支持720p和1080p,而且我的一些对象是基于棋盘宽度和高度调整大小的平铺或光标,因为这可以在我的游戏中改变,而棋盘将始终占据屏幕的相同百分比。

I have several objects with different textures for different states, so I am using a TextureAtlas made with TexturePacker, and resizing the TextureRegion where I need it. I have to resize because not only am I trying to support both 720p and 1080p, but some of my objects are tiles or cursors which resize based on the width and height of the board, as that can change in my game whereas the board will always occupy the same percentage of the screen.

使用纹理,我可以这样做:

texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

然而,当我使用 TextureRegion 时没有选项来设置过滤器。这导致这些 TextureRegion 的大小调整为锐利,块状和锯齿状。它不是很好的缩放,它似乎根本没有反别名。

However, when I am using a TextureRegion there is no option to set a filter. This results in these TextureRegions resizing as sharp, blocky, and jagged. It isn't nice scaling and it doesn't seem to anti-alias at all.

这非常令人沮丧,因为我已经足够制作图形了,现在即使我喜欢我所做的,它看起来也很糟糕。如何使用 TextureRegion 而不是复制 TextureFilter.Linear 的效果纹理

This is pretty frustrating, because I'm bad enough at making graphics and now even when I like what I've made it looks crappy. What do I do to replicate the effect of TextureFilter.Linear using a TextureRegion instead of a Texture?

推荐答案

您可以打开.atlas文件并更改过滤值到线性,线性。或者您可以使用 region.getTexture()来访问该区域所属的纹理,然后调用 setFilter(...)就可以了。

You can open your .atlas file and change the filter value to Linear, Linear. Or you can use region.getTexture() to get access to the Texture to which the region belongs, then call setFilter(...) on that.

这篇关于LibGDX:过滤缩放的TextureRegion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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