Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I take screen coordinates (or alternatively world coordinates on the 'primary' parallax plane) and find out what world coordinates they translate into when taking parallax depth into account?

I want to be able to tell if a rectangle is under the mouse cursor. I'm using libGDX and the ParallaxCamera class from the tests module. This means depth is modelled in two dimensions, where 1 == primary plane, 0 == pinned to the screen, 0,5 == scrolls at half the rate of the primary plane.

This is trivial in the primary parallax plane, as libGDX's camera has a handy unproject method. However, I can't find any examples that use the 'parallax matrix', as this is typically passed into a SpriteBatch#setProjectionMatrix rather than being used in internal camera calculations.

I don't understand the mathematics enough to figure this out. If anyone reading this can link to any very basic explanations of the mathematics behind projecting things with parallax depth into screen space and vice versa, I'd be really grateful to read it.

share|improve this question
A Parallax effect can be easily achieved. Say you have 2 sprites. Sprite1 is on layer 1 (this.layer=1), Sprite2 is on layer 0.9. When we are rendering our sprites, we apply a scale transformation on the matrix of the layer value. This allows Sprite2 to move slower than Sprite1 – Jackson Feb 27 '15 at 17:53

Your Answer


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

Browse other questions tagged or ask your own question.