draft: texture button
This commit is contained in:
38
GlobalClasses/Nodes/Scenes/CameraScene.cs
Normal file
38
GlobalClasses/Nodes/Scenes/CameraScene.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
public partial class CameraScene : Scene
|
||||
{
|
||||
private Camera2D Camera { get; set; }
|
||||
|
||||
public float MaxZoom { get; set; }
|
||||
|
||||
public float MinZoom { get; set; }
|
||||
|
||||
public float ZoomRate { get; set; }
|
||||
|
||||
private float Zoom
|
||||
{
|
||||
get => Camera.Zoom.X;
|
||||
set => Camera.Zoom = value * Vector2.One;
|
||||
}
|
||||
|
||||
[ProxyMethod]
|
||||
public virtual void __Ready()
|
||||
{
|
||||
}
|
||||
|
||||
public sealed override void _Ready()
|
||||
{
|
||||
Camera = GetNode<Camera2D>("Camera");
|
||||
__Ready();
|
||||
base._Ready();
|
||||
}
|
||||
protected void ZoomIn() => Zoom = Mathf.Max(Zoom * (1 + ZoomRate), MaxZoom);
|
||||
protected void ZoomOut() => Zoom = Mathf.Min(Zoom * (1 - ZoomRate), MinZoom);
|
||||
protected void ZoomAt(Vector2 pos) => Camera.Position = pos;
|
||||
}
|
||||
Reference in New Issue
Block a user