diff --git a/Scenes/Main/main.gd b/Scenes/Main/main.gd index 54d70fb..fb69b4b 100644 --- a/Scenes/Main/main.gd +++ b/Scenes/Main/main.gd @@ -1,13 +1,13 @@ extends Node @onready var _Map = $Map -@onready var _Player = $Player -@onready var _Camera = $WorldCamera +#@onready var _Player = $Player +#@onready var _Camera = $WorldCamera # Called when the node enters the scene tree for the first time. func _ready() -> void: - _Map.populate_terrain(_Camera.global_position) + _Map.populate_terrain($CameraController.global_position) # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: diff --git a/Scenes/Main/main.tscn b/Scenes/Main/main.tscn index ad5a6b9..32a7a5b 100644 --- a/Scenes/Main/main.tscn +++ b/Scenes/Main/main.tscn @@ -1,18 +1,24 @@ -[gd_scene load_steps=5 format=3 uid="uid://d05j5yuhlsxp0"] +[gd_scene load_steps=6 format=3 uid="uid://d05j5yuhlsxp0"] [ext_resource type="PackedScene" uid="uid://cywuuce71rmgb" path="res://Scenes/Map/map.tscn" id="1_1r6ip"] [ext_resource type="Script" uid="uid://btdvxp8ckmeb3" path="res://Scenes/Main/main.gd" id="1_qw60k"] -[ext_resource type="PackedScene" uid="uid://dh8pjs2s1kud3" path="res://Scenes/Player/player.tscn" id="2_lixft"] -[ext_resource type="Script" uid="uid://cpp4vte6rs37q" path="res://Scenes/Main/world_camera.gd" id="4_5yls4"] +[ext_resource type="Script" uid="uid://brublmhrsdc7l" path="res://Scenes/Main/camera_controller.gd" id="3_p6jpk"] +[ext_resource type="Script" uid="uid://xrddv2epi3ty" path="res://addons/smartcamera2D/SmartCamera2D.gd" id="3_qw60k"] +[ext_resource type="Texture2D" uid="uid://bq6ud1dmn8fds" path="res://addons/smartcamera2D/Camera2D.svg" id="5_2a143"] [node name="Main" type="Node"] script = ExtResource("1_qw60k") [node name="Map" parent="." instance=ExtResource("1_1r6ip")] -[node name="Player" parent="." instance=ExtResource("2_lixft")] +[node name="CameraController" type="Node2D" parent="."] +script = ExtResource("3_p6jpk") +metadata/_edit_group_ = true -[node name="WorldCamera" type="Camera2D" parent="."] -script = ExtResource("4_5yls4") +[node name="SmartCamera2D" type="Camera2D" parent="CameraController"] +script = ExtResource("3_qw60k") +target = NodePath("..") +metadata/_custom_type_script = "uid://xrddv2epi3ty" -[editable path="Player"] +[node name="Sprite2D" type="Sprite2D" parent="CameraController"] +texture = ExtResource("5_2a143") diff --git a/project.godot b/project.godot index cb31d62..da3e8fc 100644 --- a/project.godot +++ b/project.godot @@ -15,6 +15,10 @@ run/main_scene="uid://d05j5yuhlsxp0" config/features=PackedStringArray("4.4", "GL Compatibility") config/icon="res://icon.svg" +[autoload] + +CameraControl="*res://addons/smartcamera2D/CameraControl.gd" + [display] window/size/viewport_width=800 @@ -26,6 +30,10 @@ window/size/initial_screen=1 project/assembly_name="TurnBasedStrategyGame" +[editor_plugins] + +enabled=PackedStringArray("res://addons/smartcamera2D/plugin.cfg") + [input] MoveUp={