More nullable fixes, make SetTransform a part of base Renderer.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user