Народ, почему может не работать камера в Godot 4.2?
Кудрявый Чел
Ученик
(109),
на голосовании
1 неделю назад
вот код
extends Node2D
const CAM_START_POS := Vector2(220, 285) const PLAYER_START_POS := Vector2(218, 464) var speed : int var START_SPEED : int = 0 var screen_size : Vector2i # Called when the node enters the scene tree for the first time. func _ready(): screen_size = get_window().size new_game() вот код:
# Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): speed = START_SPEED $player.position.y += speed * delta $Camera2D.position.y += speed * delta
extends Node2D
const CAM_START_POS := Vector2(220, 285)
const PLAYER_START_POS := Vector2(218, 464)
var speed : int
var START_SPEED : int = 0
var screen_size : Vector2i
# Called when the node enters the scene tree for the first time.
func _ready():
screen_size = get_window().size
new_game()
вот код:
func new_game():
$player.position = PLAYER_START_POS
$player.velocity = Vector2i(0, 0)
$Camera2D.position = CAM_START_POS
$StaticBody2D.position = Vector2i(0, 0)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
speed = START_SPEED
$player.position.y += speed * delta
$Camera2D.position.y += speed * delta
if $Camera2D.position.y - $StaticBody2D.position.y > screen_size.y * 1.5:
$StaticBody2D.position.y += screen_size.y