Files
ai-game-2/MainGame.gd

53 lines
1.8 KiB
GDScript3

extends Node2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
$Node2D/background.connect("transitioned", Callable($label, "_on_transitioned"))
$Node2D/background.connect("transitioned", Callable(self, "_on_transitioned"))
reset_camera($Node2D/background)
pass # Replace with function body.
func _on_transitioned(scene):
print ("this transitioned")
reset_camera(scene)
$Node2D/label._on_transitioned(scene)
#scene.connect("transitioned", $label, "_on_transitioned")
scene.connect("transitioned", Callable(self, "_on_transitioned"))
@onready var camera:Camera2D = $Node2D/Camera2D
func reset_camera(scene):
#$Node2D.scale = Vector2(scene.background_scale, scene.background_scale)
#var far_point = self.to_global(Vector2(scene.find_child("bg").texture.get_width(), scene.find_child("bg").texture.get_height() ) )
var x:Sprite2D = scene.find_child("bg");
var height = x.texture.get_height()
var far_point = self.to_global(Vector2(x.texture.get_width(), x.texture.get_height() ) * x.get_global_transform())
print("FAR POINT IS ", far_point)
var bg = $Node2D/background
camera.make_current()
camera.limit_right = far_point.x
camera.limit_bottom=far_point.y
$Node2D/background/Graham/RemoteTransform2D.remote_path=camera.get_path()
camera.reset_smoothing()
camera.limit_right = far_point.x
camera.limit_bottom =far_point.y
#$Node2D/background/Graham/Camera2D.reset_smoothing()
#$Node2D/background/Graham/Camera2D.reset_smoothing()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
var s = $Node2D/background.ego_scale($Node2D/background/Graham)
$Node2D/background/Graham.scale = Vector2(s, s)
func _unhandled_input(event: InputEvent) -> void:
$Node2D.push_input(event)