LibGDX: Filtering a scaled TextureRegion(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
,我可以这样做:
With a Texture
, I can just do this:
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 TextureRegion
s resizing as sharp, blocky, and jagged. It isn't nice scaling and it doesn't seem to anti-alias at all.
这很令人沮丧,因为我在制作图形方面已经够糟糕了,现在即使我喜欢我制作的东西,它看起来也很糟糕.如何使用 TextureRegion
而不是 Texture
来复制 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 文件并将 filter
值更改为 Linear, Linear
.或者您可以使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:LibGDX:过滤缩放的 TextureRegion
基础教程推荐
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01