Good day! I try to draw the background in the project, I do everything as in the documentation, i.e. I draw in the render method in turn

drawStars(); drawPlanet(); 

those. first drawStars () method must be drawn, then drawPlanet (), which will be on top of drawStars (). But for some reason, everything happens the other way around drawStars () is superimposed on top.

Method code

 private void drawStars() { stars.setSize(136, 125); stars.setPosition(0, 0); stars.draw(batch); }` private void drawPlanet2() { batch.draw(planet2, 0, Gdx.graphics.getHeight() / 8, movPlanet.getWidth(), movPlanet.getHeight()); } 

What could be the problem? Thanks a lot in advance!

  • one
    Are you by any chance a developer of Cosmos Music? :) - Flippy
  • No, I'm doing another application. If interested then I can send the link. - Rumato
  • I would be very grateful) - Flippy

1 answer 1

I have this code works as you expect; Only I replaced movePlanet with specific values:

 batch.draw(planet2, 0, Gdx.graphics.getHeight() / 8, 23, 23); 

therefore, it is believed that movPlanet.getWidth() and movPlanet.getHeight() do not return what you expect; for example, some small meaning and you just do not distinguish this planet from other stars when the game is running.

  • Thanks for the answer, now there is no way to check, on Monday, accomplish your goal - Rumato