center camera on load
This commit is contained in:
parent
fe0d76e370
commit
f31a6ee0c2
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@
|
||||
export_presets.cfg
|
||||
|
||||
/AuthKey_VSYTQ75GZQ.p8
|
||||
*.dds
|
||||
|
@ -1,5 +1,4 @@
|
||||
extends Camera2D
|
||||
class_name PanningCamera2D
|
||||
|
||||
@export var MIN_ZOOM: float = 0.5
|
||||
@export var MAX_ZOOM: float = 3.0
|
||||
|
12
main.gd
Normal file
12
main.gd
Normal file
@ -0,0 +1,12 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
var center = $Field.to_global($Field.tiles[$Field.tiles.size() / 2].position)
|
||||
$Camera2D.position = center
|
||||
$Camera2D.reset_pos = center
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
pass
|
12
main.tscn
12
main.tscn
@ -1,14 +1,20 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://djirenq1psstj"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://djirenq1psstj"]
|
||||
|
||||
[ext_resource type="Script" path="res://main.gd" id="1_2dcib"]
|
||||
[ext_resource type="Script" path="res://PanningCamera/PanningCamera2D.gd" id="1_vtapg"]
|
||||
[ext_resource type="PackedScene" uid="uid://qipfodwbk1gf" path="res://Field/field.tscn" id="1_y0qkv"]
|
||||
|
||||
[node name="Main" type="Node2D"]
|
||||
script = ExtResource("1_2dcib")
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
limit_left = -5000
|
||||
limit_top = -2000
|
||||
limit_right = 5000
|
||||
limit_bottom = 4000
|
||||
editor_draw_limits = true
|
||||
script = ExtResource("1_vtapg")
|
||||
MIN_ZOOM = null
|
||||
MAX_ZOOM = null
|
||||
ZOOM_RATE = 5.0
|
||||
|
||||
[node name="Field" parent="." instance=ExtResource("1_y0qkv")]
|
||||
|
@ -15,13 +15,18 @@ run/main_scene="res://main.tscn"
|
||||
config/features=PackedStringArray("4.2", "GL Compatibility")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[debug]
|
||||
|
||||
gdscript/warnings/integer_division=0
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=1920
|
||||
window/size/viewport_height=1080
|
||||
window/vsync/vsync_mode=0
|
||||
|
||||
[rendering]
|
||||
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
renderer/rendering_method="mobile"
|
||||
renderer/rendering_method.mobile="gl_compatibility"
|
||||
textures/vram_compression/import_etc2_astc=true
|
||||
|
Loading…
Reference in New Issue
Block a user