一、下载godot
godot 是一个游戏开发平台,可以用gd语言,这一个类似python,python程序员转gd很容易,也可以用C#开发。
https://godotengine.org/ 进行下载,下载
下载,net版本。当然mac也可以下载,linux上也有可以,可以去下载相应版本。
二、因为自己的是新手,我再下载cursor进行智能编程,用其跟visual studio 2022及net 8.0进行开发。https://www.cursor.com/,在使用这一个工具后,让我对程序员这一个行业充满了失落。当然用其开时,我们也要写基本的代码,再让其进行完善。
三、在godot开发中让cursor为默认的编程器。
四、在godot开发中相关的开发习惯跟原来php 一类的不太一样,界面设计好后点选相关界面或按钮一类的进行角本挂载。
这里我们让登陆按钮挂载buttonClick.cs 即我们写的相关代码。
五、双击写好好的角本打开buttonClick.cs ,当然是我们用的cursor进行开发。
六、登陆代码:
using Godot;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json; // 引入 Newtonsoft.Json 用于处理 JSON 数据
using System.IO;
public partial class buttonClick : Button
{
// 声明私有变量
private string username;
private string password;
private string notice;
private string url = "https://www.xxx.com/api/stock/index/login"; // API 请求的 URL
private ProgressBar progressBar;
private LineEdit usernameEdit;
private LineEdit passwordEdit;
// _Ready 方法在节点准备好时调用
public override void _Ready()
{
// 获取用户名和密码输入框
usernameEdit = ((LineEdit)GetParent().GetNode("phone"));
passwordEdit = ((LineEdit)GetParent().GetNode("password"));
// 获取进度条节点
progressBar = (ProgressBar)GetParent().GetNode("%ProgressBar");
// 使用 lambda 表达式处理按钮点击事件并调用异步方法 pressclickAsync
this.Pressed += async () => await pressclickAsync();