I'm trying to draw an image using libgdx but no matter what I do, libgdx seems to insist on drawing a portion of an image I had loaded and used in an earlier game screen.
In my current game screen (class implements Screen), I have tried loading the image using both an atlas and loading it via the Texture class. However, when I draw the image in my render method, portions of an image that I had loaded previously are being displayed instead. Not the image that I am passing to the draw method!
I have tried both loading the image using a Texture Atlas and directly:
private TextureAtlas deckAtlas; private TextureRegion aceHearts; // In class constructor deckAtlas = new TextureAtlas("deck.atlas"); aceHearts = deckAtlas.findRegion("ace-heart");
Texture texture = new Texture("deck.png"); sprite = new Sprite(texture, 72, 0, 72, 100);
Depending on the method used above, I try to display by either:
game.batch.begin(); game.batch.draw(aceHearts, 100, 100); game.batch.end();
game.batch.begin(); sprite.draw(game.batch); game.batch.end();
where game is an instance of a class that extends Game and batch was initialized in that class's create method.
To start from the beginning, in my class that extends Game I call
In Main Menu Screen, I load a skin using
skin = new Skin(Gdx.files.internal("uiskin.json"));
and create a bunch of Scene.2d UI widgets with that skin (the packed image that's loaded by the skin is contributing the image that is being drawn on my next screen when I don't want it to). Finally, I create the Screen in which I am having the above problems using
So to summarize, I am loading an image in a class that implements Screen, but that image never gets drawn to the screen. Instead, an image that I had used in the previous screen is being displayed instead. Any ideas why?
Thanks for any help.
I am using libGDX 1.3.1 (I think).