Java 如何在LibGdx中使用TextureRegion.split

Java 如何在LibGdx中使用TextureRegion.split,java,libgdx,Java,Libgdx,我是游戏开发新手,正在尝试在libGDX中分割图像,但遇到了一个问题 这是我要分割的图像: 这是我的代码: textureZ60=new Texture(Gdx.files.internal("data/z63.png")); TextureRegion[][] tmp = new TextureRegion(textureZ60).split( textureZ60.getWidth() / column, textureZ60.getHeight() / row); al

我是游戏开发新手,正在尝试在libGDX中分割图像,但遇到了一个问题

这是我要分割的图像:

这是我的代码:

textureZ60=new Texture(Gdx.files.internal("data/z63.png"));
TextureRegion[][] tmp = new TextureRegion(textureZ60).split(
    textureZ60.getWidth() / column,
    textureZ60.getHeight() / row);

allFramesZ0 = new TextureRegion[column*row];

int index=0;
for (int i=0; i<row; i++) {
    for (int j=column-1; j>=0; j--) {
        allFramesZ0[index++]=tmp[i][j];
    }
}
animationZ0 = new Animation(0.25f, allFramesZ0);
textureZ60=新纹理(Gdx.files.internal(“data/z63.png”);
TextureRegion[][]tmp=新的TextureRegion(textureZ60)。拆分(
textureZ60.getWidth()/列,
textureZ60.getHeight()/行);
allFramesZ0=新纹理区域[列*行];
int指数=0;
对于(int i=0;i=0;j--){
allFramesZ0[index++]=tmp[i][j];
}
}
animationZ0=新动画(0.25f,allFramesZ0);
我的问题是,如果我让数组降序,它将返回6
TextureRegion

  • 0-橙色
  • 1-黑色
  • 2-红色
  • 3-红色
  • 4-红色
  • 5-红色
如果我使数组升序,它将返回6
TextureRegion

  • 0红色
  • 1-绿色
  • 2-橙
  • 3-橙
  • 4-橙
  • 5-橙
我尝试了所有的方法,但它没有返回所有6种不同的图像。为什么它会重复红色或橙色,我如何才能得到所有6个不同的图像


请帮我做这个。谢谢。

我已经检查并调试了它,它正在使用正确的数据创建6个不同的纹理区域。似乎你的问题与动画有关-也许你使用的帧速率有多大的错误或其他什么。 你如何播放你的动画?它是在重复还是只重复一次? 从您描述的内容来看,它似乎向前跳了3帧,最后在最后一帧停止。请注意,橙色到黑色和红色到绿色之间都有3个帧。
如果你只是简单地播放了一次,也许你应该尝试反复播放,以首先验证所有加载的帧是否都是无效的(但播放顺序可能是错误的:红色->绿色->紫色->红色->…)。此外,如果您再添加一个帧,它将不会重复,您可能无法看到所有颜色。

请提供
变量的值。@plastique column=6和row=1代码似乎正常。。。当你说它没有返回全部6张图片时,你是什么意思?分裂?你的回路?动画?@plastique 6分钟图像。全部6种颜色。Cor返回1 rad、1 green和全部橙色。我不知道粉色、蓝色、黑色在哪里谢谢你为我做这件事我认为你应该使用的正确帧速率是1/25f或1/30f。