gd: added input addon
This commit is contained in:
16
guide_examples/mouse_position_2d/background.gd
Normal file
16
guide_examples/mouse_position_2d/background.gd
Normal file
@ -0,0 +1,16 @@
|
||||
## This just keeps the sprite endlessly scrolling. It's not related to input.
|
||||
extends Sprite2D
|
||||
|
||||
|
||||
func _process(delta):
|
||||
# get rect of visible screen in world coordinates
|
||||
var rect = get_viewport().canvas_transform.affine_inverse() * get_viewport_rect()
|
||||
# fit the bg into the viewport
|
||||
global_position = rect.position
|
||||
global_scale = rect.size / texture.get_size()
|
||||
|
||||
# update scaling so the texture scales according to zoom level
|
||||
material.set_shader_parameter("scale", global_scale)
|
||||
var offset = rect.position / texture.get_size()
|
||||
# and offset so we pick a texture offset relative to the movement of the camera
|
||||
material.set_shader_parameter("offset", offset)
|
Reference in New Issue
Block a user