Fix MathUtils.LerpVector2, add cameras.
This commit is contained in:
@@ -8,6 +8,14 @@ public class TestPlayer : RectangleShape2d
|
||||
{
|
||||
base.OnStart();
|
||||
Color = Color.Cyan;
|
||||
_logger.Echo("OnStart");
|
||||
|
||||
_camera = new Camera2d()
|
||||
{
|
||||
Current = true,
|
||||
};
|
||||
|
||||
Layer.AddEntity(_camera);
|
||||
}
|
||||
|
||||
protected override void OnUpdate(double dt)
|
||||
@@ -19,7 +27,11 @@ 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);
|
||||
}
|
||||
|
||||
private Logger _logger = new(nameof(TestPlayer));
|
||||
private float _speed = 200f;
|
||||
private Camera2d _camera;
|
||||
}
|
||||
Reference in New Issue
Block a user