I have a scrolling world (like in Skyway), but it only scrolls, by moveing all objects. How can I move the background image of the world?
/**
* Creates a moving textur on the background image of the world.
*/
protected final void createTextur() {
int x;
int y;
if (totalXMovement > 0) {
for (x = totalXMovement; x > 0; x -= textur.getWidth()) {
;
}
}
else {
for (x = totalXMovement; x < 0; x += textur.getWidth()) {
;
}
x -= textur.getWidth();
}
if (totalYMovement > 0) {
for (y = totalYMovement; y > 0; y -= textur.getHeight()) {
;
}
}
else {
for (y = totalYMovement; y < 0; y += textur.getHeight()) {
;
}
y -= textur.getHeight();
}
getBackground().clear();
for (int i = x; i < getWidth(); i += textur.getWidth()) {
for (int j = y; j < getHeight(); j += textur.getHeight()) {
getBackground().drawImage(textur, i, j);
}
}
}