1
\$\begingroup\$

In LibGDX, what is the connection between these concepts: stage, camera, viewport, batch (spritebatch), projection matrix, tiledmap?

Currently my game has

3 stages:

  • UI stage
  • entity stage
  • tiledmap stage

2 cameras:

  • hud camera (for UI)
  • map camera (for map)

2 batches:

  • spritebatch for rendering particles
  • batch from the tiled map renderer (used in map and entity stage)

3 viewports:

  • for entity stage
  • for UI stage
  • for tiled map stage

I am very confused at this point at how all these components connect. My whole game works, except when I resize my main menu screen, the particles in my next screen get drawn in the wrong position. Meaning that the resize information does not reach the particle drawer.

I feel like the reason I am having a lot of trouble debugging it, is because I don't understand well enough how they relate to each other.

Can anyone help me clarifying this structure?

\$\endgroup\$
0
\$\begingroup\$

I'll try to explain this based on my own experience so this might be not correct. For more trusted information check this out in case you didn't know: https://github.com/libgdx/libgdx/wiki/Scene2d

Stage

Imagine the stage as the container holding all your elements that need to be rendered/updated.

Camera

Determines what parts of the stage are visible (based on the viewport)

Batches

Are responsible for rendering everything (doing all the needed open gl stuff)

Viewport

Manages the camera and controls how the stage is displayed on the screen (aspect ratio etc)

To help you with your problem some screenshots / code pieces would be useful but sounds like after resizing the new viewport dimensions are not send to the batch rendering the particles

I hope this helped a bit but again for better information take a look in the wiki.

Blakk

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.