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

相关推荐
wsjsf2 小时前
智能代码审查助手的搭建
java·学习·ai编程
xuhaoyu_cpp_java3 小时前
MyBatis学习(二)
java·经验分享·笔记·学习·mybatis
石榴树下的七彩鱼3 小时前
智能抠图 API 多语言接入实战:从零到上线的 Python / Java / PHP / JS 完整教程(附避坑指南)
java·python·php·智能抠图·api接入·石榴智能·shiliuai
无限进步_3 小时前
C++ 继承机制完全解析:从基础原理到菱形继承问题
java·开发语言·数据结构·c++·vscode·后端·算法
roman_日积跬步-终至千里3 小时前
【系统架构师案例题-知识点】数据库与缓存设计
数据库·缓存·系统架构
SamDeepThinking3 小时前
适合中小型企业的出口入口网关微服务
java·后端·架构
不知名的忻3 小时前
并查集(QuickUnion)
java·数据结构·算法·并查集
likerhood3 小时前
Java实现选择题选项乱序算法
java·开发语言·算法
我登哥MVP3 小时前
【SpringMVC笔记】 - 11 - SpringMVC 执行流程
java·spring boot·笔记·spring·tomcat·intellij-idea
笨蛋不要掉眼泪4 小时前
面试篇-java基础上
java·后端·面试·职场和发展