Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

The question is at the end, as it requires a bit of context.

I'm not sure if my understanding, my code, or LibGDX's ParallaxCamera is wrong.

LibGDX's ParallaxCamera uses Matrix4s to achieve a parallax effect by transforming the vertices used in a SpriteBatch#draw call.

Depth is modelled as a float between 1 and 0. 1 means move directly proportionally to the camera; 0 means never move; 0.5 would move half as fast as the foreground.

Suppose I have a screen of 320x240. My camera is pointing at 160,120. What should be the screen coords for the following things?

World Coords    Depth    Screen Coords?
0,0             0,0      0,0

160,0           0.5,0    160,0
320,0           0.5,0    240,0

160,0           0.75,0   160,0
320,0           0.75,0   ???,0

160,0           1,0      160,0

I was expecting that if the camera is at X:160, then all things with world coords with X:160 should be drawn at screen coords with X:160. My thinking is that effectively that means everything should be 'lined up', and that moving the camera should give the impression of them all moving away from that point at different rates.

As it stands, my code is drawing something with X:160 and xDepth:0.5 at screenX:240. I don't think that's right, but I don't know if I'm misunderstanding what should happen, my code is wrong, or if the camera is wrong :(

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.