63 lines
2.4 KiB
GDScript3
63 lines
2.4 KiB
GDScript3
extends Node2D
|
|
|
|
|
|
# Declare member variables here. Examples:
|
|
# var a = 2
|
|
# var b = "text"
|
|
var cursors = [load("res://boot_icon.png"), load("res://eye_icon.png"), load("res://hand_icon.png"), load("res://speech_icon.png")]
|
|
var cursor_index = 0
|
|
func get_scene() -> Scene:
|
|
return $SceneViewport/background
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
# get_scene().connect("transitioned", Callable($SceneViewport/label, "_on_transitioned"))
|
|
get_scene().connect("transitioned", Callable(self, "_on_transitioned"))
|
|
reset_camera(get_scene())
|
|
|
|
pass # Replace with function body.
|
|
|
|
|
|
func _on_transitioned(scene):
|
|
reset_camera(scene)
|
|
$SceneViewport/label._on_transitioned(scene)
|
|
camera.position = Vector2(0,0 )
|
|
#scene.connect("transitioned", $SceneViwport/label, "_on_transitioned")
|
|
scene.connect("transitioned", Callable(self, "_on_transitioned"))
|
|
|
|
@onready var camera:Camera2D = $SceneViewport/PlayerTracker/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())
|
|
camera.make_current()
|
|
camera.limit_right = far_point.x
|
|
camera.limit_bottom=far_point.y
|
|
get_scene().get_node("Graham/RemoteTransform2D").remote_path=$SceneViewport/PlayerTracker.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 player = get_scene().get_node("Graham")
|
|
$SceneViewport/PlayerTracker/Camera2D.set_target(player.facing)
|
|
var s = get_scene().ego_scale(player)
|
|
player.scale = Vector2(s, s)
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
$SceneViewport.push_input(event)
|
|
|
|
func _input(event):
|
|
if event.is_action_released("quit"):
|
|
get_tree().quit()
|
|
if event.is_action_released("right_click"):
|
|
ActionState.current_action = (ActionState.current_action + 1) % 4
|
|
Input.set_custom_mouse_cursor(cursors[ActionState.current_action])
|