Juan Mitchell
Juan Mitchell

Reputation: 622

Can I zoom just a part of my OrthograficCamera libgdx

imagine that, an imaginary minecraft, where you build cubes.

You have a panel where you have the diferents cubes(tool box),

and other big panel, the world where you build, but the world is bigger.

and all of this things are in the same screen, imagine how can i put a orthografic camera that only zoom the panel where you have the whole world, that it allows you to zoom and build cubes with details and presicion, but the tool box panel still the same position. always visible. ?

Upvotes: 0

Views: 597

Answers (2)

P.T.
P.T.

Reputation: 25177

Use two cameras. One for the "game" and one for the "HUD".

During a render call, use one camera to render the game, then "switch" cameras and then render the HUD. How you switch cameras depends on what API you're using to render objects (for example use setProjectionMatrix on a SpriteBatch).

You could also create more than one SpriteBatch or more than one Stage (as each tracks camera state internally), but they're a bit heavy-weight.

Beware that when switching contexts, you will probably have to explicitly end/flush/complete the first context before starting the second.

Upvotes: 1

bemeyer
bemeyer

Reputation: 6231

You do not use one Camera to show the stuff. For example you use a Camera for the background of your game and you have a second camera for the game Hud that always has a fixed size. But the game in background can be zoomed in and out because its an different camera.
But for simple boxes on the screen you do not use a second camera. You just use one more Stage that get displayed or not where the new "ui" stuff is shown.

Hope this helps a bit.

Upvotes: 0

Related Questions