Android game scrolling background
Posted
by
Stevanicus
on Game Development
See other posts from Game Development
or by Stevanicus
Published on 2011-02-04T18:41:38Z
Indexed on
2011/02/04
23:35 UTC
Read the original article
Hit count: 205
Hi There,
I'm just trying to figure out the best approach for running a scolling background on an android device. The method I have so far.... its pretty laggy. I use threads, which I believe is not the best bet for android platforms
@Override
public void run() {
// Game Loop
while(runningThread){
//Scroll background down
bgY += 1;
try {
this.postInvalidate();
t.sleep(10);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
where postinvalidate in the onDraw function simply pushings the background image down
canvas.drawBitmap(backgroundImage, bgX, bgY, null);
Thanks in advance
© Game Development or respective owner