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

相关推荐
Seven9720 小时前
Condition底层机制剖析:多线程等待与通知机制
java
怒放吧德德1 天前
Spring Boot 实战:RSA+AES 接口全链路加解密(防篡改 / 防重放)
java·spring boot·后端
郑州光合科技余经理1 天前
代码展示:PHP搭建海外版外卖系统源码解析
java·开发语言·前端·后端·系统架构·uni-app·php
大大水瓶1 天前
Tomcat
java·tomcat
dustcell.1 天前
haproxy七层代理
java·开发语言·前端
游离态指针1 天前
以为发消息=下单成功?RabbitMQ从0到秒杀实战的完整踩坑笔记
java
BD_Marathon1 天前
工厂方法模式
android·java·工厂方法模式
玹外之音1 天前
Spring AI MCP 无状态服务器实战:构建AI智能用户管理系统
java·后端
java干货1 天前
Redis 的 ZipList 是什么?它是怎么解决内存碎片问题的?
java
失重外太空啦1 天前
Tomcat
java·服务器·tomcat