gpt4 book ai didi

java - 纹理区域分割不起作用

转载 作者:行者123 更新时间:2023-12-01 12:19:38 25 4
gpt4 key购买 nike

当我尝试分割纹理时,它不起作用,当我在屏幕上绘制它时,它会绘制与原始纹理相同的 4 个纹理。我使用以下代码来分割纹理。

texture = new Texture(Gdx.files.internal("fondo1.png"));
TextureRegion[][] regs = TextureRegion.split(texture, texture.getWidth() / 2, texture.getHeight() / 2);
Random rand = new Random();
int x,y;
for (int i=0; i < regs.length; i++){
for (int j = 0; j < regs[i].length; j++){
x = rand.nextInt(500);
y = rand.nextInt(500);
parts.add(new ImageActor(regs[i][j].getTexture(),x,y, regs[i][j].getRegionWidth(), regs[i][j].getRegionHeight()));
}
}

然后纹理会加载到 Actor 子类中并通过舞台进行绘制。

有什么建议吗?谢谢

最佳答案

我怀疑您的问题出在 ImageActor 构造函数的第一个参数中。您将通过调用 regs[i][j].getTexture() 来发送完整纹理。

TextureRegiongetTexture() 方法返回 Region 引用的完整纹理。

您应该向其发送 TextureRegion regs[i][j],并修改您的 ImageActor,以便它可以接收并绘制 TextureRegion .

关于java - 纹理区域分割不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26789568/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com