Godot 学习笔记(1):环境配置

文章目录

前言

我从小就有个梦想,我想做游戏。虽然我大学的时候选择了计算机,工作也是计算机,但是我一直没有时间去学游戏引擎。原因有二:第一,我刚开始工作并没有那么强的代码能力。第二,我工作并不是写游戏代码。

那么为什么我要选择Godot呢?原因如下

  • Godot.net有 C# 的代码支持
  • Godot.net 2d已经足够完善,而作为独立游戏开发,完全没必要去做3d游戏,因为2d游戏已经足够。
  • 不喜欢Unity。Godot 开源免费。

Godot 环境配置

我目前的环境是

  • godot.net 4.2.1
  • visual studio 2022
  • window 10
  • .net core 8.0

相关链接

Godot 初学
Godot VisualStudio外部编辑器设置
Godot 添加Nuget 引用
Godot 添加信号

注意,我这里默认你已经了解最简单的Godot 编辑器操作。并且完成了上面博客的功能。

最简单的按钮项目

这里新建两个控件,按钮控件和文本控件。

Sence打包


最简单的按钮事件

csharp 复制代码
using Godot;
using System;
using System.Diagnostics;

public partial class test_node : Node2D
{
    // Called when the node enters the scene tree for the first time.

    private Label _lable;

    private Button _button;

    private int num = 0;

    public override void _Ready()
    {
        _lable = this.GetNode<Label>("Label");

        _button = this.GetNode<Button>("Button");

        _lable.Text = "修改";

        _button.ButtonDown += _button_ButtonDown;
    }

    public void _button_ButtonDown()
    {
        _lable.Text = $"按下修改{num}";
        GD.Print($"按下修改{num}");
        num++;
    }

    // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _Process(double delta)
    {
    }

}

总结

这里简单讲解了Godot的基础和简单的项目案例。我们后面大部分的功能都是基于button和lable来实现的。下一节我们将讲解最复杂的信号。

相关推荐
考虑考虑4 小时前
JDK26中的Map.ofLazy
java·后端·java ee
鶴哥只手遮天7 小时前
Spring AI 2.0.1 深度解析-第 14 章 MCP 服务端(上):注解式实现与工具来源
java·人工智能·开源
鶴哥只手遮天7 小时前
Spring AI 2.0.1 深度解析-第 15 章 MCP 服务端(下):三种协议形态、Streamable 传输与状态管理
java·人工智能·开源
鶴哥只手遮天7 小时前
Spring AI 2.0.1 深度解析-第 16 章 向量存储(上):`VectorStore` 接口体系、`BatchingStrategy`
java·人工智能·开源
鶴哥只手遮天7 小时前
Spring AI 2.0.1 深度解析-第 12 章 工具循环的流式形态、Usage 累加与扩展体系
java·人工智能·开源
鶴哥只手遮天7 小时前
Spring AI 2.0.1 深度解析-第 23 章 模型供应商实现:从 `OpenAiSetup` 到 Bedrock
java·人工智能·开源
鶴哥只手遮天7 小时前
Spring AI 2.0.1 深度解析-第 06 章 内置 Advisor 全景:13 个实现逐个剖到源码级
java·人工智能·开源
鶴哥只手遮天7 小时前
Spring AI 2.0.1 深度解析-第 03 章 消息体系与 Prompt:不可变模型、`ChatOptions` 与模板渲染
java·人工智能·开源
鶴哥只手遮天7 小时前
Spring AI 2.0.1 深度解析-第 24 章 生产实践与 2.x 迁移:陷阱清单、AOT 与调优
java·人工智能·开源
鶴哥只手遮天7 小时前
Spring AI 2.0.1 深度解析-第 10 章 工具调用(中):执行链路、结果转换与工具限制
java·人工智能·开源