More nullable fixes, make SetTransform a part of base Renderer.

This commit is contained in:
2024-01-21 17:58:11 +01:00
parent 5f4e32e2e0
commit 5bb16350f3
8 changed files with 59 additions and 59 deletions

View File

@@ -14,7 +14,10 @@ public class TestPlayer : RectangleShape2d
Current = true,
};
Layer.AddEntity(_camera);
if (Layer is not null)
{
Layer.AddEntity(_camera);
}
}
protected override void OnUpdate(double dt)
@@ -27,10 +30,13 @@ public class TestPlayer : RectangleShape2d
var velocity = Input.GetInputDirection("left", "right", "up", "down") * _speed;
Position += velocity * (float)dt;
_camera.Position = MathUtils.LerpVector2(_camera.Position, Position, dt * 5f);
if (_camera is not null)
{
_camera.Position = MathUtils.LerpVector2(_camera.Position, Position, dt * 5f);
}
}
private Logger _logger = new(nameof(TestPlayer));
private float _speed = 200f;
private Camera2d _camera;
private Camera2d? _camera;
}