LIbGDX: prefered way to code for map (and player) scrolling

Hi,

I’m trying to rewrite my code of my Knightmareg based game (see youtube vid at bottom) to incorporate LIbGDX.
The way how i formarly (when i was still using applet) set up my map scroll is this:

  • I’ve got a map that 4800 pixels in height
  • In the draw method of my main class I had it start displaying my map at 800 pixels from the bottom left (my original GameHeight = 800px)
  • then in my backgrounds class at every update i have that Y coordinate incremented by 1 pixel on every update untill the top left Y coordinate of my map drawn on screen (at 0,0) reaches the top left of the map.
    -(one problem I then have to work around is that the draw method uses (int) and i can’t slow my scroll down by using a value less then 1)

Now I could do the same in my LibGDX project but it just doesnt seem like the best way to do this.

One way, I’ve been thinking of, to create my new scroll is instead of updating the position where my map is drawn is to move libgdx’s orthographic camera viewport around and create my scroll like this.
This also would mean that i have to change the players position to always be relative to the viewports position.

[b]My question (before I start coding doing this all):

Would you also do it like this?

Or do you know if a preferred(/better) way to handle my (vertical) map scroll?[/b]

bmb_7p_kI1M