Better screen
This commit is contained in:
18
MainGame.gd
18
MainGame.gd
@@ -4,6 +4,8 @@ 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
|
||||
|
||||
@@ -19,10 +21,11 @@ func _ready():
|
||||
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/Camera2D
|
||||
@onready var camera:Camera2D = $SceneViewport/PlayerTracker/Camera2D
|
||||
|
||||
func reset_camera(scene):
|
||||
#$Node2D.scale = Vector2(scene.background_scale, scene.background_scale)
|
||||
@@ -30,11 +33,10 @@ func reset_camera(scene):
|
||||
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)
|
||||
camera.make_current()
|
||||
camera.limit_right = far_point.x
|
||||
camera.limit_bottom=far_point.y
|
||||
get_scene().get_node("Graham/RemoteTransform2D").remote_path=camera.get_path()
|
||||
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
|
||||
@@ -45,8 +47,18 @@ func reset_camera(scene):
|
||||
# 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"):
|
||||
cursor_index = cursor_index +1
|
||||
if cursor_index >= cursors.size():
|
||||
cursor_index = 0
|
||||
Input.set_custom_mouse_cursor(cursors[cursor_index])
|
||||
|
||||
Reference in New Issue
Block a user