Center player with vertical scrolling

  • #1, by ygmantellMonday, 24. July 2017, 14:26 7 years ago
    So in my game, the player can go up a fire escape, and to do this, I just made a tall background.  The problem is that the player is not centered on screen.  When trying to go back down, the player sorta gets stuck towards the bottom of the visible play-area, and you cant click lower.
    I set it up so you can scroll when your cursor is at the edge of the screen, but it's not a very pretty fix.
    Any way to have the "camera" stay on the player as he moves vertically?

    I used the script below for horizontal centering, but I'm afraid that if I try to alter it to make it vertical, I will mess it up... smile

    Any ideas?
    game.GameHorizontalScrollDistance = (game.WindowResolution.x / 2) -- 50% resolution width

    Great Poster

    274 Posts


  • #2, by afrlmeMonday, 24. July 2017, 15:00 7 years ago
    Vertical would be same except...
    game.GameVerticalScrollDistance = (game.WindowResolution.y / 2)

    Imperator

    7285 Posts

  • #3, by ygmantellMonday, 24. July 2017, 15:06 7 years ago
    Thaaaats what I thought.  Didn't want to mess with it myself...
    Thanks so much!

    Great Poster

    274 Posts