Jump to content

  • Log In with Google      Sign In   
  • Create Account


Mehmet Turan

Member Since 16 May 2012
Offline Last Active May 18 2012 11:22 AM
-----

Posts I've Made

In Topic: How can I add a parallax effect into my side-scrolling game?

17 May 2012 - 05:12 AM

This looks like a translation issue. Can you post more code other than the above? It's really hard to tell with just those two methods. Show us how you create the backgrounds, the camera, and the update and paint processes. Most likely you reset the translate coordinate or something.

Have you tried stepping through the code in a debugger and looking at the values of the variables you are using?


I have updated my codes.

In Topic: How can I add a parallax effect into my side-scrolling game?

16 May 2012 - 05:06 PM

Can you post your actual code for how you move the background? Are you using integer coordinates? (In which case you might just be getting rounding errors that truncate 1/2 to 0 and thus the background never moves, etc.)


My code is the same with in my first post.I'm translating it with back.x+=7f;

I'm using floats.

In Topic: How can I add a parallax effect into my side-scrolling game?

16 May 2012 - 04:40 PM

The trick to 2D parallax is to just move the background at a slower rate than the foreground. Try something like moving your "back" layer 1 pixel every time the foreground scrolls 2 pixels (i.e. divide the rate of foreground scroll by 2 to get the rate of background scroll).


Thanks for your reply.I know how to simulate parallax but my problem is different i think.When i move my camera and character my background don't scroll.I have to scroll them but i couldn't do it.It draws continuously at same position.When i translate them with same amount with my camera translate,parallax effect don't work.

PARTNERS