Demo Finish
This commit is contained in:
24
Scenes/ViewerCamera.cs
Normal file
24
Scenes/ViewerCamera.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Godot;
|
||||
|
||||
public partial class ViewerCamera : Camera2D
|
||||
{
|
||||
private static readonly Vector2 ZoomMin = new(0.02001f, 0.02001f);
|
||||
|
||||
private static readonly Vector2 ZoomMax = new(4f, 4f);
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (@event is InputEventMouseButton eb)
|
||||
{
|
||||
if (eb.IsPressed())
|
||||
{
|
||||
if (eb.ButtonIndex == MouseButton.WheelDown)
|
||||
if (Zoom.X > ZoomMin.X && Zoom.Y > ZoomMin.Y)
|
||||
Zoom -= new Vector2(0.01f, 0.01f);
|
||||
if(eb.ButtonIndex == MouseButton.WheelUp)
|
||||
if (Zoom.X < ZoomMax.X && Zoom.Y < ZoomMax.Y)
|
||||
Zoom += new Vector2(0.01f, 0.01f);
|
||||
}
|
||||
}
|
||||
base._Input(@event);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user