-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCamera.cs
40 lines (34 loc) · 1.04 KB
/
Camera.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Godot;
using System;
public partial class Camera : Camera2D
{
private double q = 0;
public override void _Process(double delta)
{
var zoom = GetWindow().Size / new Vector2(640, 360);
var num = ((int)Math.Round(Mathf.Min(zoom.X, zoom.Y) * 10)) / 10;
Zoom = new(num, num);
if (Input.IsActionJustPressed("fullscreen"))
{
if (DisplayServer.WindowGetMode() != DisplayServer.WindowMode.Fullscreen)
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Fullscreen);
else
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Windowed);
}
var quitting = GetNode<Control>("quitting");
var m = quitting.Modulate;
quitting.Modulate = new Color(m.R, m.G, m.B, (float)q);
if (Input.IsActionPressed("ui_cancel"))
{
q += delta;
if (q > 1.2)
{
GetTree().Quit();
}
}
else
{
q = Math.Max(0, q - delta * 5);
}
}
}