You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,12 @@ Welcome to the tutorial about character movement suited for beginners starting g
5
5
## What you'll learn?
6
6
7
7
- Building Blocks: How collections, game objects, and components relate to each other
8
-
- Animations: How to new add animation groups to an atlas
8
+
- Animations: How to add new animation groups to an atlas
9
9
- Input: How to capture key presses in a script, and add new bindings
10
10
- Logic: How to move a game object using vectors and `dt`, and switch animations based on movement direction
11
11
- Camera: How to follow character and zoom
12
12
13
-
This is a short tutorial, might take about 15 minutes to complete, but you can stay and play around with it more.
13
+
This is a short tutorial, it will take about 15 minutes to complete, but you can stay and play around with it more.
14
14
15
15
## Before you start
16
16
@@ -52,17 +52,17 @@ A few core terms will appear throughout the tutorial:
52
52
53
53
<imgsrc="doc/3.png">
54
54
55
-
So `main.collection` is a file with all the game objects, that are spawned into the game's world. The components are part of game objects. You can see on the right site, in the <kbd>Outline</kbd> pane the root "Collection" and the tree-like structure of what's in it.
55
+
So `main.collection` is a file with all the game objects, that are spawned into the game's world. The components are part of game objects. You can see on the right side, in the <kbd>Outline</kbd> pane the root "Collection" and the tree-like structure of what's in it.
56
56
57
57
In this collection there are 3 game objects:
58
58
59
59
1. <kbd>`camera`</kbd>, an embedded game object with camera component to see the game's world
60
-
2. <kbd>`character`</kbd>, created from the blueprint file ["/main/character.go"](defold://open?path=/main/character.go).
60
+
2. <kbd>`character`</kbd>, created from the prototype file (also known as "prefab" or "blueprint" in other engines)["/main/character.go"](defold://open?path=/main/character.go).
61
61
3. <kbd>`level`</kbd>, an embedded game object with a tilemap component that uses ["/main/level.tilemap"](defold://open?path=/main/level.tilemap).
62
62
63
63
<imgsrc="doc/4.png">
64
64
65
-
Using a blueprint file such as `character.go` makes an object reusable. Embedded objects (like the `camera` or `level`) are fine when you only need a single instance. You can read more about [Basic Building Blocks of Defold here](https://defold.com/manuals/building-blocks/).
65
+
Using a prototype file such as `character.go` makes an object reusable. Embedded objects (like the `camera` or `level`) are fine when you only need a single instance. You can read more about [Basic Building Blocks of Defold here](https://defold.com/manuals/building-blocks/).
66
66
67
67
## Inspect the character
68
68
@@ -80,15 +80,15 @@ Select the sprite component in the `Outline` and look at its properties:
80
80
-`Image` points to ["/main/character.atlas"](defold://open?path=/main/character.atlas)
81
81
-`Default Animation` is set to `idle`
82
82
83
-
The sprite already knows how to play the idle animation. You can preview it by clicking the <kbd>Space</kbd>, when it's selected in the Outline.
83
+
The sprite already knows how to play the idle animation. You can preview it by pressing the <kbd>Space</kbd> key, when it's selected in the Outline.
84
84
85
85
But we want the character to move, so we will add the walk animations that the script can switch between.
86
86
87
87
## Add the walk animations
88
88
89
89
Open ["/main/character.atlas"](defold://open?path=/main/character.atlas).
90
90
91
-
An atlas stores separate images and animations. Right now it only contains the `idle` animation - you can select it in the `Outline` and preview with <kbd>View</kbd> ▸ <kbd>Play</kbd> or by clicking <kbd>Space</kbd>.
91
+
An atlas stores separate images and animations. Right now it only contains the `idle` animation - you can select it in the `Outline` and preview with <kbd>View</kbd> ▸ <kbd>Play</kbd> or by pressing <kbd>Space</kbd> key.
92
92
93
93
94
94
1. Right click the root of the <kbd>Atlas<kbd> outline and choose <kbd>Add Animation</kbd> (or shortcut<kbd>A</kbd>).
@@ -102,7 +102,7 @@ An atlas stores separate images and animations. Right now it only contains the `
102
102
103
103
<imgsrc="doc/7.png">
104
104
105
-
6. You can notice that when you preview the animation (with <kbd>Space</kbd>) it's too fast, so, while holding <kbd>Shift</kbd> select all of the new animations added in the `Outline` and in the `Properties` pane set the <kbd>FPS</kbd> property to <kbd>15</kbd>.
105
+
6. You can notice that when you preview the animation (with <kbd>Space</kbd>) key it's too fast, so, while holding <kbd>Shift</kbd> select all of the new animations added in the `Outline` and in the `Properties` pane set the <kbd>FPS</kbd> property to <kbd>15</kbd>.
106
106
107
107
<imgsrc="doc/8.png">
108
108
@@ -112,11 +112,11 @@ At the end of the steps in the tutorial, don't forget to save everything. Select
112
112
113
113
If the atlas is zoomed out too far, use <kbd>View</kbd> ▸ <kbd>Frame Selection</kbd> (shortcut <kbd>F</kbd>) or scroll to adjust the zooom.
114
114
115
-
At this point the atlas contains every animation the astronaut needs, but the script still only plays `idle`.
115
+
At this point the atlas contains every animation the character needs, but the script still only plays `idle`.
116
116
117
117
## Open the movement script
118
118
119
-
Open ["/main/astronaut.script"](defold://open?path=/main/astronaut.script).
119
+
Open ["/main/character.script"](defold://open?path=/main/character.script).
120
120
You can get back to our character game object and double-click on the character script, or open it using learned methods.
121
121
122
122
The script will be opened in a built-in code editor, and it includes already the standard script template with empty lifecycle functions. For this tutorial you only need three callbacks:
@@ -177,7 +177,7 @@ function on_input(self, action_id, action)
177
177
end
178
178
```
179
179
180
-
We simply compare here the current <kbd>action_id</kbd> with each of the ones defined in input bindings as <kbd>`actions`</kbd> and modify the <kbd>`direction`</kbd> vector. Each active input action updates one part of the direction vector. If two keys are held at the same time, both axes can be set, which gives diagonal movement.
180
+
We simply compare here the current <kbd>action_id</kbd> with each of the ones defined in input bindings as <kbd>`actions`</kbd> and modify the <kbd>`direction`</kbd> vector. Each active input action updates one part of the direction vector. If two keys are held at the same time, both axis can be set, which gives diagonal movement.
181
181
182
182
### Move the game object every frame
183
183
@@ -233,7 +233,7 @@ Play with the speed value to adjust the speed of the movement of the character t
233
233
234
234
## Play the correct animation
235
235
236
-
The astronaut moves now, but the sprite still stays in the <kbd>`idle`</kbd> animation.
236
+
The character moves now, but the sprite still stays in the <kbd>`idle`</kbd> animation.
237
237
238
238
To fix it add at the end of our <kbd>`update()`</kbd> function, after setting the position, but just before reseting the direction, this fragment:
0 commit comments