Skip to content

Instantly share code, notes, and snippets.

@identity2
Created June 8, 2019 13:00
Show Gist options
  • Save identity2/776ff7abba81f5ba86a525c4fea4a8ff to your computer and use it in GitHub Desktop.
Save identity2/776ff7abba81f5ba86a525c4fea4a8ff to your computer and use it in GitHub Desktop.
# Being called when loaded.
func _ready():
screen_size = self.get_viewport_rect().size
# Actually scroll the screen. (Update the viewport according to the position of the camera.)
func update_viewport():
var canvas_transform = self.get_viewport().get_canvas_transform()
canvas_transform.o = -self.get_global_pos() + screen_size / 2.0
self.get_viewport().set_canvas_transform(canvas_transform)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment