how to flip a pixmap to draw to a texture in libgdx?

前端 未结 2 614
甜味超标
甜味超标 2020-12-19 00:41

So what I\'m trying to do is to generate a background image for my game by drawing pixmaps to a texture. So far I can do that, but now I need to draw the pixmaps flipped in

2条回答
  •  Happy的楠姐
    2020-12-19 01:01

    I also don't see other option except to iterate the pixels:

    public Pixmap flipPixmap(Pixmap src) {
        final int width = src.getWidth();
        final int height = src.getHeight();
        Pixmap flipped = new Pixmap(width, height, src.getFormat());
    
        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
                flipped.drawPixel(x, y, src.getPixel(width - x - 1, y));
            }
        }
        return flipped;
    }
    

提交回复
热议问题