level start zoom out before changing states
This commit is contained in:
parent
2d3df6bdca
commit
4fe3d252b5
1 changed files with 24 additions and 0 deletions
|
|
@ -1,6 +1,9 @@
|
|||
extends LevelState
|
||||
|
||||
|
||||
var trans_tween: Tween
|
||||
|
||||
|
||||
func _enter(_previous_state_path: String, _data: Dictionary = {"round": 0, "restart": false}) -> void:
|
||||
get_tree().paused = true
|
||||
assert((_data["round"] as int) in range(3), "round number is invalid")
|
||||
|
|
@ -36,6 +39,8 @@ func _enter(_previous_state_path: String, _data: Dictionary = {"round": 0, "rest
|
|||
level.player_1 = _instantiate_player(1)
|
||||
level.player_2 = _instantiate_player(2)
|
||||
level.ball = _instantiate_ball()
|
||||
|
||||
_trans_zoom_out(level.ball.global_position, Vector2(4,4), 2)
|
||||
|
||||
|
||||
func _instantiate_player(id: int) -> Player:
|
||||
|
|
@ -62,3 +67,22 @@ func _instantiate_ball() -> Ball:
|
|||
b.global_position = s.global_position
|
||||
|
||||
return b
|
||||
|
||||
|
||||
func _trans_zoom_out(pos: Vector2, zoom_in: Vector2, duration: float = 1) -> void:
|
||||
if trans_tween:
|
||||
trans_tween.kill()
|
||||
|
||||
assert(trans_tween == null, "transgender tween wasnt nulled")
|
||||
|
||||
trans_tween = create_tween()
|
||||
|
||||
level.camera.global_position = pos
|
||||
level.camera.zoom = zoom_in
|
||||
trans_tween.tween_property(level.camera, "zoom", Vector2(1,1), duration).set_trans(Tween.TRANS_BOUNCE).set_ease(Tween.EASE_OUT)
|
||||
trans_tween.tween_callback(func() -> void:
|
||||
# TODO: PLAYING state
|
||||
#finished.emit(PLAYING)
|
||||
get_tree().paused = false
|
||||
trans_tween = null
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue