当我从翻转的textureRegion创建它时,LibGDX无法使用NinePatchDrawable作为表格的背景

问题描述

这是我想做的事

`TextureRegion region = new TextureRegion(new Texture("path to the file"));
 region.flip(false,true);
 NinePatch patch = new NinePatch(region,left,right,up,down);
 NinePatchDrawable drawable = new NinePatchDrawable(patch);
 Table table = new Table();
 table.setBackground(drawable);
 table.add(someLabel);
`

当我在舞台上添加表格时,我可以看到标签,但是没有背景,如果没有翻转textureRegion,同样可以奏效,有人可以向我解释为什么吗?

解决方法

之所以会这样,是因为TextureRegion.flip()会更改u / v和u2 / v2坐标。从NinePatch创建TextureRegion的方式仅使用纹理,并且x / y从该TextureRegion共存。此时,u / v / u2 / v2信息已丢失。

看起来NinePatch(TextureRegion... patches)构造函数可能保留了该信息,但我没有尝试过。