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

I'm developing a 2D side-scrolling game.I have a scrollable bitmap for background with size 2400x480.How can i scroll this bitmap?I have searched for algorithms but i can't find any solution.

I know that i can do it with following code:

for(int i=0;i<100;i++)

So it will scroll bitmap for 240000 pixels.

But i don't want to draw images which stays out of screen(with size 800x480).

How can i render scrolling tile?How can i give velocity to it?(For parallax scrolling after normal scrolling)

share|improve this question

This is not how you should scroll your bitmap. You should override the draw method and measure the time from the last draw,with this time you will know how much pixels you have to scroll your bitmap. Imagine your CPU is super-fast, with your code, the bitmap will scroll at the speed of light!

share|improve this answer
Are there any algorithm for this issue?I searched a lot but i can't find any solution. – droidmachine May 7 '12 at 10:57
It's not an issue.your algorythm was bad designed. How could you imagine that the background scroll at the good speed if you don't even use a time-related parameter? – VinceFR May 7 '12 at 11:42
The problem isn't that.My draw function is time independent.I'm using deltaTime for animations only.I don't know much about scrolling.If i learn its logic i can create an algorithm. – droidmachine May 8 '12 at 19:17
Scrolling is an animation too. – VinceFR May 9 '12 at 8:24
Any sample or tutorial for that? – droidmachine May 9 '12 at 15:32

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.