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.

I implemented ParallaxScrolling for my SideScroller project, everything is working but the tiled map (the most important part!). I've been trying out everything but it doesn't work (see the code below).

I'm using ParallaxCamera from GdxTests, it's working perfectly for the background layers.

I can't explain myself properly in english, so I recorded 2 videos:

Before parallaxScrolling

After parallaxScrolling

As you can see, now the platforms appear in the middle of the Y-axis.

I've got a Map class with 2 tiled maps, so I need two renderers too:

private TiledMapRenderer renderer1;
private TiledMapRenderer renderer2;



public void update(GameCamera camera) {
renderer1.setView(camera.calculateParallaxMatrix(1f, 0f), camera.position.x - camera.viewportWidth / 2, 
           **camera.position.y - camera.viewportHeight/2**, camera.viewportWidth, camera.viewportHeight);
renderer2.setView(camera.calculateParallaxMatrix(1f, 0f), camera.position.x - camera.viewportWidth / 2,
           **camera.position.y - camera.viewportHeight/2**, camera.viewportWidth, camera.viewportHeight);
}

In bold, the code I think I should change. I've tried changing parameters, even adding hardcoded values, etc, but one of two: 1. Nothing happens. 2. Platforms disappear.

Here is some aditional code. The render method:

     world.update(delta);
    parallaxBackground.update(camera);

    clear(0.5f, 0.7f, 1.0f, 1);

    batch.setProjectionMatrix(camera.calculateParallaxMatrix(0, 0));
    batch.disableBlending();
    batch.begin();
    batch.draw(background, -(int)background.getRegionWidth()/2, -(int)background.getRegionHeight()/2);
    batch.end();
    batch.enableBlending();

    parallaxBackground.draw(batch, camera);
    renderer.render(batch);
share|improve this question
1  
Just to clarify the issue, after you implemented parallax scrolling, the platforms are now drawing too high up on the screen? I'm not sure why the y values should change at all when implementing scrolling on the x axis. Why not just set the y axis camera view to the same as it was before implementing parallax scrolling? –  Byte56 Jul 2 '13 at 20:38
    
Hi. I did it, but it doesn't work. I recorded a video so you can see how I change values: screenr.com/OfxH –  kirchhoff Jul 2 '13 at 22:26
add comment

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.