save code
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class number_change : Label3D
|
||||
{
|
||||
private Label3D _label3D;
|
||||
private int _currentNumber = 13; // 初始数字
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
// 尝试获取Label3D节点
|
||||
//_label3D = GetNodeOrNull<Label3D>("Label3D");
|
||||
|
||||
_label3D = this;
|
||||
|
||||
|
||||
// 初始化显示
|
||||
UpdateDisplay();
|
||||
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
// 检测回车键按下
|
||||
if (@event is InputEventKey keyEvent && keyEvent.Pressed)
|
||||
{
|
||||
if (keyEvent.Keycode == Key.Enter || keyEvent.Keycode == Key.KpEnter)
|
||||
{
|
||||
// 数字增加
|
||||
_currentNumber++;
|
||||
|
||||
// 更新显示
|
||||
UpdateDisplay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDisplay()
|
||||
{
|
||||
if (_label3D != null)
|
||||
{
|
||||
_label3D.Text = _currentNumber.ToString();
|
||||
}
|
||||
}
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user