[Hands with you Godot game developers] Case I: Progress 1: Hello World

Progress effect

Here Insert Picture Description

step

1. Import Resources

Resources drag the entire folder to the file system below Godot
Here Insert Picture Description
Here Insert Picture Description

2. Add a "Game" node

A very important part of the work to develop games with Godot is to add and edit the various "nodes" (see official documents "scenario and node") , as well as the type of node has a name, in the following order to facilitate the distinction between the type of node names with the code mark He said the name indicated by double quotes. For example: type "Game" is a nodeNode

In fact, the nodes are organized Godot is very flexible, this is just my way of doing this kind of organization selected game. The "Game" is the root node data on the entire game logic

Here Insert Picture DescriptionFind the Nodenode below and then click the 创建button

You will notice that this list is a tree structure table, in fact, inheritance Godot node of this table also mark

Here Insert Picture DescriptionDouble-click the node, and its name was changed to "Game"
Here Insert Picture Description

Then press the shortcut keys Ctrl + Ssave this scene

The default extension scenario is "tscn", t represents text, scn represent scene, marking this file is human-readable, curious to see if you can use Notepad to open

Here Insert Picture Description
After saving is complete, you'll see one more "Game.tscn" file in the file system window
Here Insert Picture Description

3. Add background

In 2D systems, called nodes for display picture Spritenode (Node Wizard), so we want to "Game" to add a Spritetype of child node
Here Insert Picture Description
can enter the type of node to look directly in the search box

Here Insert Picture DescriptionThe name was changed to "Background"

A game in which the structure of the scene will be very complicated, so you must get a reasonable naming the node management. Each time you add a node, it must immediately confirm the name is appropriate.

Here Insert Picture Description
Select "Background", drag the resource bg.jpg Textureposition behind the field

在选定一个节点时编辑器右边的属性栏中会显示它的属性
Here Insert Picture Description这样,背景图就显示在 “Game”的编辑窗口了。但是,实际上只有紫色区域才是游戏运行时的可视区域,背景图并没有填满这个区域,而且这个区域本身的比例也不是原作那样“竖屏”的。
Here Insert Picture Description

4. 设置分辨率

我们先来调整一下这个游戏的分辨率

Here Insert Picture Description

把Width和Height分别设置为750和1334,这是iPhone7的分辨率

Here Insert Picture Description好了,这回可视区域变成“竖屏”了,接下来我们再调整一下图片的位置和大小。

Here Insert Picture Description

5. 调整背景图的大小和位置

我们选顶“Background”在它属性栏的NodesD>Transform中将Position的x/y分别设为375(1334/2)和667(1334/2).这样背景图片就覆盖了整个可视区域,并且略大一些(为了避免一些穿帮情况)
Here Insert Picture Description

7. 运行一下

Here Insert Picture Description
《[手把手带你Godot游戏开发]Godot界面介绍》中,介绍了这几个按钮,我们点击第一个 运行项目(F5)按钮试一下。第一次点它的话,会弹出来一个对话框。这是因为我们没有为这个项目设置“主场景”,我们只需设置一次就可以了。
.
点击选择
Here Insert Picture Description
在选择主场景窗口找到我们的“Game.tscn”点击打开
Here Insert Picture Description
这就是你的第一个Godot“游戏”,尽管只是显示了一个简单的背景,不过很快就会不一样了。
Here Insert Picture Description

8.作业

别着急下课,尝试着在文件系统中找到这个图片

Here Insert Picture Description

然后在"Game"中,搭建成下面这个样子

Here Insert Picture Description
看起来不难,但是有些人的结果可能会是下面这个样子。如果你的地面也被草坪挡住了,尝试解决一下这个问题

Here Insert Picture Description

Published 337 original articles · won praise 369 · views 110 000 +

Guess you like

Origin blog.csdn.net/hello_tute/article/details/104534235