3

First off, with my background in XNA i just cannot get used to the inverted Y axis. So in LibGDX i flipped the OrthographicCamera with cam.setToOrtho(true,width, height) but this obviously ends up in drawing all my textures upside down.

I can create Sprites and TextureRegions from all my textures to flip each and every one of them but that takes a lot of extra code. So is there a efficient way to have all my textures flipped around there center?

I tried adding a flipped matrix to the spritebatch transformMatrix but that cancels out the flipped ortho cam. I also tried to create a Sprite for drawing all my textures and flips them but without success.

Madmenyo
  • 8,389
  • 7
  • 52
  • 99

1 Answers1

4

you can probably just use flip, like so.

textureRegion.flip(false, true);

for every TextureRegion you have.

Since Sprites extend TextureRegions, this should work for them too

clearlyspam23
  • 1,624
  • 13
  • 15
  • I currently just use Texture and use that straight inside the spritebatch.draw method. So this does add some extra work, isn't there a way to just set all Textures, textureRegions or sprites to be flipped? And by flipped i mean read flipped not actually flip the image "physically" so performance wise about the same. – Madmenyo Jul 17 '14 at 18:24
  • 1
    I can actually create a texture region by: texture = new TextureRegion(new Texture("badlogic.jpg")); and then just draw it like i always do. Texture region also gives me more options then a regular texture besides flip so i will start using this. Still curious if there is a way to flip every texture without using region.flip on every region. – Madmenyo Jul 17 '14 at 18:35
  • 1
    @Menno Gouw I believe sprite batch has a [similar method](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/SpriteBatch.html#draw-com.badlogic.gdx.graphics.Texture-float-float-float-float-float-float-float-float-float-int-int-int-int-boolean-boolean-). You might be able to just give your image source inverted height when you draw it, although I am unsure if this would work. I doubt there is much of a performance difference either way. – clearlyspam23 Jul 17 '14 at 18:35