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来实现的。下一节我们将讲解最复杂的信号。

相关推荐
Mahir081 小时前
Spring 循环依赖深度解密:从问题本质到三级缓存源码级解析
java·后端·spring·缓存·面试·循环依赖·三级缓存
RyFit2 小时前
SpringAI 常见问题及解决方案大全
java·ai
石山代码3 小时前
C++ 内存分区 堆区
java·开发语言·c++
绝知此事3 小时前
【算法突围 01】线性结构与哈希表:后端开发的收纳术
java·数据结构·算法·面试·jdk·散列表
无风听海3 小时前
C# 隐式转换深度解析
java·开发语言·c#
一只大袋鼠4 小时前
Git 进阶(二):分支管理、暂存栈、远程仓库与多人协作
java·开发语言·git
德思特4 小时前
从 Dify 配置页理解 RAG 的重要参数
java·人工智能·llm·dify·rag
YOU OU5 小时前
Spring IoC&DI
java·数据库·spring
один but you5 小时前
从可变参数到 emplace:现代 C++ 性能优化的核心组合
java·开发语言
是码龙不是码农6 小时前
ThreadPoolExecutor 7 个核心参数详解
java·线程池·threadpool