Camera Animation works now
This commit is contained in:
parent
5e5547f4a2
commit
c5aa58c16d
@ -7,11 +7,14 @@ onready var player = get_node("/root/Map1/Player")
|
|||||||
func _ready():
|
func _ready():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
var once = true
|
||||||
|
var lockedPlayerCamera = false
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
CameraToPlayer()
|
CameraToPlayer()
|
||||||
# TestCamera()
|
if once:
|
||||||
|
AnimateMoveCamera(player.position, Vector2(player.position.x - 10,player.position.y - 10), "position", 2)
|
||||||
|
once = false
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#Move camera to position
|
#Move camera to position
|
||||||
@ -19,16 +22,18 @@ func MoveCamera(x, y):
|
|||||||
position.x = x
|
position.x = x
|
||||||
position.y = y
|
position.y = y
|
||||||
|
|
||||||
|
func _on_Tween_tween_completed(object, key):
|
||||||
|
print(object, key)
|
||||||
|
lockedPlayerCamera = false
|
||||||
|
|
||||||
func TestCamera():
|
func AnimateMoveCamera(source, destination, key, time):
|
||||||
var t = player.position
|
lockedPlayerCamera = true
|
||||||
t.x = 100
|
var tween = get_node("/root/Map1/Tween")
|
||||||
t.y = 100
|
tween.interpolate_property(get_node("/root/Map1/Camera2D"), key, source, destination, time, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
|
||||||
MoveCamera(t.x, t.y)
|
tween.start()
|
||||||
# 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
|
#Move camera close to player
|
||||||
func CameraToPlayer():
|
func CameraToPlayer():
|
||||||
MoveCamera(player.position.x, player.position.y)
|
if lockedPlayerCamera == false:
|
||||||
|
MoveCamera(player.position.x, player.position.y)
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user