Progress effect
step
1. Import Resources
Resources drag the entire folder to the file system below Godot
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 node
Node
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
Find the Node
node 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
Double-click the node, and its name was changed to "Game"
Then press the shortcut keys Ctrl + S
save 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
After saving is complete, you'll see one more "Game.tscn" file in the file system window
3. Add background
In 2D systems, called nodes for display picture Sprite
node (Node Wizard), so we want to "Game" to add a Sprite
type of child node
can enter the type of node to look directly in the search box
The 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.
Select "Background", drag the resource bg.jpg Texture
position behind the field
在选定一个节点时编辑器右边的属性栏中会显示它的属性
这样,背景图就显示在 “Game”的编辑窗口了。但是,实际上只有紫色区域才是游戏运行时的可视区域,背景图并没有填满这个区域,而且这个区域本身的比例也不是原作那样“竖屏”的。
4. 设置分辨率
我们先来调整一下这个游戏的分辨率
把Width和Height分别设置为750和1334,这是iPhone7的分辨率
好了,这回可视区域变成“竖屏”了,接下来我们再调整一下图片的位置和大小。
5. 调整背景图的大小和位置
我们选顶“Background”在它属性栏的NodesD>Transform中将Position的x/y分别设为375(1334/2)和667(1334/2).这样背景图片就覆盖了整个可视区域,并且略大一些(为了避免一些穿帮情况)
7. 运行一下
在《[手把手带你Godot游戏开发]Godot界面介绍》中,介绍了这几个按钮,我们点击第一个 运行项目(F5)
按钮试一下。第一次点它的话,会弹出来一个对话框。这是因为我们没有为这个项目设置“主场景”,我们只需设置一次就可以了。
.
点击选择
在选择主场景窗口找到我们的“Game.tscn”点击打开
这就是你的第一个Godot“游戏”,尽管只是显示了一个简单的背景,不过很快就会不一样了。
8.作业
别着急下课,尝试着在文件系统
中找到这个图片
然后在"Game"中,搭建成下面这个样子
看起来不难,但是有些人的结果可能会是下面这个样子。如果你的地面也被草坪挡住了,尝试解决一下这个问题