Seperated camera from player

This commit is contained in:
EljakimHerrewijnen 2020-09-21 20:45:28 +02:00
parent b65ed88772
commit 5e5547f4a2
3 changed files with 97 additions and 57 deletions

View File

@ -18,4 +18,3 @@ func _ready():
func _on_Btn_PlayGame_pressed(): func _on_Btn_PlayGame_pressed():
get_tree().change_scene("res://river_intersection_home2.tscn") get_tree().change_scene("res://river_intersection_home2.tscn")
pass # Replace with function body.

34
Tilemap_CameraView.gd Normal file
View File

@ -0,0 +1,34 @@
extends Camera2D
onready var player = get_node("/root/Map1/Player")
# Called when the node enters the scene tree for the first time.
func _ready():
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
CameraToPlayer()
# TestCamera()
pass
#Move camera to position
func MoveCamera(x, y):
position.x = x
position.y = y
func TestCamera():
var t = player.position
t.x = 100
t.y = 100
MoveCamera(t.x, t.y)
# var tween = get_node("/root/Map1/Tween")
# tween.interpolate_property(get_node("/root/Map1/Camera2D"), "position", player.position, t, 200, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
# tween.start()
#Move camera close to player
func CameraToPlayer():
MoveCamera(player.position.x, player.position.y)

File diff suppressed because one or more lines are too long