Center player with vertical scrolling

  • #1, z ygmantellMonday, 24. July 2017, 14:26 hodinky 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

    Čestný člen

    274 Posts


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

    Imperátor

    7285 Posts

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

    Čestný člen

    274 Posts