Skip to content

Commit ff4d0b2

Browse files
committed
Merge branch 'master' of https://github.com/defold/doc
2 parents d3d0b2f + 7525881 commit ff4d0b2

File tree

93 files changed

+3691
-1763
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+3691
-1763
lines changed

.wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ OpenType
290290
OSX
291291
OTF
292292
particlefx
293+
particlefxs
293294
PEM
294295
performant
295296
Phaser

docs/en/en.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,20 @@
908908
"description": "This course teaches you to build a farming RPG in Defold, covering player control, crop systems, day progression, sprite atlases, data management, and UI design. Basic Defold and Lua knowledge is needed. Gain skills for advanced and complex projects.",
909909
"image": "/courses/images/zenva.png",
910910
"author": "Zenva"
911+
},
912+
{
913+
"path": "https://academy.zenva.com/product/defold-action-rpg-course/?utm_source=defold&utm_medium=partners&utm_campaign=defold&utm_content=defold-website",
914+
"name": "Make a Fully-Fledged 2D Action RPG in Defold",
915+
"description": "This course covers building a complete 2D action RPG in Defold, teaching core mechanics like player control, enemy AI, dynamic cameras, health bars, scene management, and spawning systems.",
916+
"image": "/courses/images/zenva.png",
917+
"author": "Zenva"
918+
},
919+
{
920+
"path": "https://academy.zenva.com/product/defold-block-breaker-course/?utm_source=defold&utm_medium=partners&utm_campaign=defold&utm_content=defold-website",
921+
"name": "Create a Block Breaker Game in Defold",
922+
"description": "This course covers building a complete block breaker game in Defold, teaching physics-based gameplay, paddle and ball mechanics, and procedural block generation using scripting.",
923+
"image": "/courses/images/zenva.png",
924+
"author": "Zenva"
911925
}
912926
],
913927
"resources": [

docs/en/manuals/debugging-native-code-ios.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ You have a few options to debug an app
8383

8484
1. Either choose `Debug` -> `Attach to process...` and select the app from there
8585

86-
1. Or choose the `Attach to process by PID or Process name`
86+
2. Or choose the `Attach to process by PID or Process name`
8787

8888
![select_device](images/extensions/debugging/ios/attach_to_process_name.png)
8989

90-
1. Start the app on the device
90+
3. Start the app on the device
9191

92-
1. In `Edit Scheme` add the <AppName>.app folder as the executable
92+
4. In `Edit Scheme` add the <AppName>.app folder as the executable
9393

9494
### Debug symbols
9595

docs/en/manuals/debugging-native-code.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,21 @@ You can [upload the debug symbols to Google Play](https://developer.android.com/
102102
$ ls <project>/build/<platform>/[lib]dmengine[.exe|.so]
103103
```
104104

105-
1. Unzip to a folder:
105+
2. Unzip to a folder:
106106

107107
```sh
108108
$ unzip dmengine.apk -d dmengine_1_2_105
109109
```
110110

111-
1. Find the callstack address
111+
3. Find the callstack address
112112

113113
E.g. in the non symbolicated callstack it could look like this
114114

115115
`#00 pc 00257224 libmy_game_name.so`
116116

117117
Where *`00257224`* is the address
118118

119-
1. Resolve the address
119+
4. Resolve the address
120120

121121
```sh
122122
$ arm-linux-androideabi-addr2line -C -f -e dmengine_1_2_105/lib/armeabi-v7a/libdmengine.so _address_
@@ -133,13 +133,13 @@ Note: If you get hold of a stack trace from the [Android logs](/manuals/debuggin
133133
# it will produce a Contents/Resources/DWARF/dmengine
134134
```
135135

136-
1. If you're not using Native Extensions, download the vanilla symbols:
136+
2. If you're not using Native Extensions, download the vanilla symbols:
137137

138138
```sh
139139
$ wget http://d.defold.com/archive/<sha1>/engine/arm64-darwin/dmengine.dSYM
140140
```
141141

142-
1. Symbolicate using load address
142+
3. Symbolicate using load address
143143

144144
For some reason, simply putting the address from the callstack doesn't work (i.e. load address 0x0)
145145

docs/en/manuals/editor-scripts.md

Lines changed: 216 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,17 @@ You can interact with the editor using `editor` package that defines this API:
5656
- for atlas animations: `images` (same as `images` in atlas)
5757
- for tilemaps: `layers` (list of editor nodes for layers in the tilemap)
5858
- for tilemap layers: `tiles` (an unbounded 2d grid of tiles), see `tilemap.tiles.*` for more info
59+
- for particlefx: `emitters` (list of emitter editor nodes) and `modifiers` (list of modifier editor nodes)
60+
- for particlefx emitters: `modifiers` (list of modifier editor nodes)
61+
- for collision objects: `shapes` (list of collision shape editor nodes)
62+
- for GUI files: `layers` (list of layer editor nodes)
5963
- some properties that are shown in the Properties view when you have selected something in the Outline view. These types of outline properties supported:
6064
- `strings`
6165
- `booleans`
6266
- `numbers`
6367
- `vec2`/`vec3`/`vec4`
6468
- `resources`
65-
69+
- `curves`
6670
Please note that some of these properties might be read-only, and some might be unavailable in different contexts, so you should use `editor.can_get` before reading them and `editor.can_set` before making editor set them. Hover over property name in Properties view to see a tooltip with information about how this property is named in editor scripts. You can set resource properties to `nil` by supplying `""` value.
6771
- `editor.can_get(node_id, property)` — check if you can get this property so `editor.get()` won't throw an error.
6872
- `editor.can_set(node_id, property)` — check if `editor.tx.set()` transaction step with this property won't throw an error.
@@ -123,16 +127,17 @@ return M
123127
Editor expects `get_commands()` to return an array of tables, each describing a separate command. Command description consists of:
124128

125129
- `label` (required) — text on a menu item that will be displayed to the user
126-
- `locations` (required) — an array of either `"Edit"`, `"View"`, `"Project"`, `"Debug"`, `"Assets"`, `"Bundle"` or `"Outline"`, describes a place where this command should be available. `"Edit"`, `"View"`, `"Project"` and `"Debug"` mean menu bar at the top, `"Assets"` means context menu in Assets pane, `"Outline"` means context menu in Outline pane, and `"Bundle"` means **Project → Bundle** submenu.
130+
- `locations` (required) — an array of either `"Edit"`, `"View"`, `"Project"`, `"Debug"`, `"Assets"`, `"Bundle"`, `"Scene"` or `"Outline"`, describes a place where this command should be available. `"Edit"`, `"View"`, `"Project"` and `"Debug"` mean menu bar at the top, `"Assets"` means context menu in Assets pane, `"Outline"` means context menu in Outline pane, and `"Bundle"` means **Project → Bundle** submenu.
127131
- `query` — a way for command to ask editor for relevant information and define what data it operates on. For every key in `query` table there will be corresponding key in `opts` table that `active` and `run` callbacks receive as argument. Supported keys:
128132
- `selection` means this command is valid when there is something selected, and it operates on this selection.
129133
- `type` is a type of selected nodes command is interested in, currently these types are allowed:
130134
- `"resource"` — in Assets and Outline, resource is selected item that has a corresponding file. In menu bar (Edit or View), resource is a currently open file;
131135
- `"outline"` — something that can be shown in the Outline. In Outline it's a selected item, in menu bar it's a currently open file;
136+
- `"scene"` — something that can be rendered to the Scene.
132137
- `cardinality` defines how many selected items there should be. If `"one"`, selection passed to command callback will be a single node id. If `"many"`, selection passed to command callback will be an array of one or more node ids.
133138
- `argument` — command argument. Currently, only commands in `"Bundle"` location receive an argument, which is `true` when the bundle command is selected explicitly and `false` on rebundle.
134139
- `id` - command identifier string, used e.g. for persisting the last used bundle command in `prefs`
135-
- `active` - a callback that is executed to check that command is active, expected to return boolean. If `locations` include `"Assets"` or `"Outline"`, `active` will be called when showing context menu. If locations include `"Edit"` or `"View"`, active will be called on every user interaction, such as typing on keyboard or clicking with mouse, so be sure that `active` is relatively fast.
140+
- `active` - a callback that is executed to check that command is active, expected to return boolean. If `locations` include `"Assets"`, `"Scene"` or `"Outline"`, `active` will be called when showing context menu. If locations include `"Edit"` or `"View"`, active will be called on every user interaction, such as typing on keyboard or clicking with mouse, so be sure that `active` is relatively fast.
136141
- `run` - a callback that is executed when user selects the menu item.
137142

138143
### Use commands to change the in-memory editor state
@@ -269,6 +274,214 @@ editor.transact({
269274
})
270275
```
271276

277+
#### Editing particlefx
278+
279+
You can edit particlefx using `modifiers` and `emitters` properties. For example, adding a circle emitter with acceleration modifier is done like this:
280+
```lua
281+
editor.transact({
282+
editor.tx.add("/fire.particlefx", "emitters", {
283+
type = "emitter-type-circle",
284+
modifiers = {
285+
{type = "modifier-type-acceleration"}
286+
}
287+
})
288+
})
289+
```
290+
Many particlefx properties are curves or curve spreads (i.e. curve + some randomizer value). Curves are represented as a table with a non-empty list of `points`, where each point is a table with the following properties:
291+
- `x` - the x coordinate of the point, should start at 0 and end at 1
292+
- `y` - the value of the point
293+
- `tx` (0 to 1) and `ty` (-1 to 1) - tangents of the point. E.g., for an 80-degree angle, `tx` should be `math.cos(math.rad(80))` and `ty` should be `math.sin(math.rad(80))`.
294+
Curve spreads additionally have a `spread` number property.
295+
296+
For example, setting a particle lifetime alpha curve for an already existing emitter might look like this:
297+
```lua
298+
local emitter = editor.get("/fire.particlefx", "emitters")[1]
299+
editor.transact({
300+
editor.tx.set(emitter, "particle_key_alpha", { points = {
301+
{x = 0, y = 0, tx = 0.1, ty = 1}, -- start at 0, go up quickly
302+
{x = 0.2, y = 1, tx = 1, ty = 0}, -- reach 1 at 20% of a lifetime
303+
{x = 1, y = 0, tx = 1, ty = 0} -- slowly go down to 0
304+
}})
305+
})
306+
```
307+
Of course, it's also possible to use the `particle_key_alpha` key in a table when creating an emitter. Additionally, you can use a single number instead to represent a "static" curve.
308+
309+
#### Editing collision objects
310+
311+
In addition to default outline properties, collision objects define `shapes` node list property. Adding new collision shapes is done like this:
312+
```lua
313+
editor.transact({
314+
editor.tx.add("/hero.collisionobject", "shapes", {
315+
type = "shape-type-box" -- or "shape-type-sphere", "shape-type-capsule"
316+
})
317+
})
318+
```
319+
Shape's `type` property is required during creation and cannot be changed after the shape is added. There are 3 shape types:
320+
- `shape-type-box` - box shape with `dimensions` property
321+
- `shape-type-sphere` - sphere shape with `diameter` property
322+
- `shape-type-capsule` - capsule shape with `diameter` and `height` properties
323+
324+
#### Editing GUI files
325+
326+
In addition to outline properties, GUI nodes defines the following properties:
327+
- `layers` — list of layer editor nodes (reorderable)
328+
- `materials` — list of material editor nodes
329+
330+
It's possible to edit GUI layers using editor `layers` property, e.g.:
331+
```lua
332+
editor.transact({
333+
editor.tx.add("/main.gui", "layers", {name = "foreground"}),
334+
editor.tx.add("/main.gui", "layers", {name = "background"})
335+
})
336+
```
337+
Additionally, it's possible to reorder layers:
338+
```lua
339+
local fg, bg = table.unpack(editor.get("/main.gui", "layers"))
340+
editor.transact({
341+
editor.tx.reorder("/main.gui", "layers", {bg, fg})
342+
})
343+
```
344+
Similarly, fonts, materials, textures, and particlefxs are edited using `fonts`, `materials`, `textures`, and `particlefxs` properties:
345+
```lua
346+
editor.transact({
347+
editor.tx.add("/main.gui", "fonts", {font = "/main.font"}),
348+
editor.tx.add("/main.gui", "materials", {name = "shine", material = "/shine.material"}),
349+
editor.tx.add("/main.gui", "particlefxs", {particlefx = "/confetti.material"}),
350+
editor.tx.add("/main.gui", "textures", {texture = "/ui.atlas"})
351+
})
352+
```
353+
These properties don't support reordering.
354+
355+
Finally, you can edit GUI nodes using `nodes` list property, e.g.:
356+
```lua
357+
editor.transact({
358+
editor.tx.add("/main.gui", "nodes", {
359+
type = "gui-node-type-box",
360+
position = {20, 20, 20}
361+
}),
362+
editor.tx.add("/main.gui", "nodes", {
363+
type = "gui-node-type-template",
364+
template = "/button.gui"
365+
}),
366+
})
367+
```
368+
Built-in node types are:
369+
- `gui-node-type-box`
370+
- `gui-node-type-particlefx`
371+
- `gui-node-type-pie`
372+
- `gui-node-type-template`
373+
- `gui-node-type-text`
374+
375+
If you are using spine extension, you can also use `gui-node-type-spine` node type.
376+
377+
If the GUI file defines layouts, you can get and set the values from layouts using `layout:property` syntax, e.g.:
378+
```lua
379+
local node = editor.get("/main.gui", "nodes")[1]
380+
381+
-- GET:
382+
local position = editor.get(node, "position")
383+
pprint(position) -- {20, 20, 20}
384+
local landscape_position = editor.get(node, "Landscape:position")
385+
pprint(landscape_position) -- {20, 20, 20}
386+
387+
-- SET:
388+
editor.transact({
389+
editor.tx.set(node, "Landscape:position", {30, 30, 30})
390+
})
391+
pprint(editor.get(node, "Landscape:position")) -- {30, 30, 30}
392+
```
393+
394+
Layout properties that were set can be reset to their default values using `editor.tx.reset`:
395+
```lua
396+
print(editor.can_reset(node, "Landscape:position")) -- true
397+
editor.transact({
398+
editor.tx.reset(node, "Landscape:position")
399+
})
400+
```
401+
Template node trees can be read, but not edited — you can only set node properties of the template node tree:
402+
```lua
403+
local template = editor.get("/main.gui", "nodes")[2]
404+
print(editor.can_add(template, "nodes")) -- false
405+
local node_in_template = editor.get(template, "nodes")[1]
406+
editor.transact({
407+
editor.tx.set(node_in_template, "text", "Button text")
408+
})
409+
print(editor.can_reset(node_in_template, "text")) -- true (overrides a value in the template)
410+
```
411+
412+
#### Editing game objects
413+
414+
It's possible to edit components of a game object file using editor scripts. The components come in 2 flavors: referenced and embedded. Referenced components use type `component-reference` and act as references to other resources, only allowing overrides of go properties defined in scripts. Embedded components use types like `sprite`, `label`, etc., and allow editing of all properties defined in the component type, as well as adding sub-components like shapes of collision objects. For example, you can use the following code to set up a game object:
415+
```lua
416+
editor.transact({
417+
editor.tx.add("/npc.go", "components", {
418+
type = "sprite",
419+
id = "view"
420+
}),
421+
editor.tx.add("/npc.go", "components", {
422+
type = "collisionobject",
423+
id = "collision",
424+
shapes = {
425+
{
426+
type = "shape-type-box",
427+
dimensions = {32, 32, 32}
428+
}
429+
}
430+
}),
431+
editor.tx.add("/npc.go", "components", {
432+
type = "component-reference",
433+
path = "/npc.script"
434+
id = "controller",
435+
__hp = 100 -- set a go property defined in the script
436+
})
437+
})
438+
```
439+
440+
#### Editing collections
441+
It's possible to edit collections using editor scripts. You can add game objects (embedded or referenced) and collections (referenced). For example:
442+
```lua
443+
local coll = "/char.collection"
444+
editor.transact({
445+
editor.tx.add(coll, "children", {
446+
-- embbedded game object
447+
type = "go",
448+
id = "root",
449+
children = {
450+
{
451+
-- referenced game object
452+
type = "go-reference",
453+
path = "/char-view.go"
454+
id = "view"
455+
},
456+
{
457+
-- referenced collection
458+
type = "collection-reference",
459+
path = "/body-attachments.collection"
460+
id = "attachments"
461+
}
462+
},
463+
-- embedded gos can also have components
464+
components = {
465+
{
466+
type = "collisionobject",
467+
id = "collision",
468+
shapes = {
469+
{type = "shape-type-box", dimensions = {2.5, 2.5, 2.5}}
470+
}
471+
},
472+
{
473+
type = "component-reference",
474+
id = "controller",
475+
path = "/char.script",
476+
__hp = 100 -- set a go property defined in the script
477+
}
478+
}
479+
})
480+
})
481+
```
482+
483+
Like in the editor, referenced collections can only be added to the root of the edited collection, and game objects can only be added to embedded or referenced game objects, but not to referenced collections or game objects within these referenced collections.
484+
272485
### Use shell commands
273486

274487
Inside the `run` handler, you can write to files (using `io` module) and execute shell commands (using `editor.execute()` command). When executing shell commands, it's possible to capture the output of a shell command as a string and then use it in code. For example, if you want to make a command for formatting JSON that shells out to globally installed [`jq`](https://jqlang.github.io/jq/), you can write the following command:

docs/en/manuals/extender-local-setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Once you have the above mentioned software installed follow these steps to insta
7272
cp ${TMP_DIR}/$(ls ${TMP_DIR} | grep server-${EXTENDER_VERSION}.jar) ${APPLICATION_DIR}/extender.jar
7373
cp ${TMP_DIR}/$(ls ${TMP_DIR} | grep manifestmergetool-${MANIFESTMERGETOOL_VERSION}.jar) ${APPLICATION_DIR}/manifestmergetool.jar
7474
```
75-
7. __Start the server__ - We can now start the server by running the docker compose main command:
75+
6. __Start the server__ - We can now start the server by running the docker compose main command:
7676
```sh
7777
docker compose -p extender -f server/docker/docker-compose.yml --profile <profile> up
7878
```

docs/en/manuals/factory.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ The project setting *max_instances* in *Collection related settings* limits the
263263

264264
If you set *max_instances* to 1024 and have 24 manually placed game objects in your main collection, you can spawn an additional 1000 game objects. As soon as you delete a game object, you are free to spawn another instance.
265265

266-
267266
## Pooling of game objects
268267

269268
It may seem like a good idea to save spawned game objects in a pool and reuse them. However, the engine is already doing object pooling under the hood so additional overhead will only slow things down. It is both faster and cleaner to delete game objects and spawn new ones.

docs/en/manuals/gui.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,9 @@ function init(self)
120120

121121
-- get the new texture file assigned to the texture with id 'theme'
122122
print(go.get("#gui", "textures", { key = "theme" })) -- /assets/mytheme.atlas
123-
124123
end
125124
```
126125

127-
128126
## Dependencies
129127

130128
The resource tree in a Defold game is static so any dependencies that you need for your GUI nodes need to be added to the component. The *Outline* groups all dependencies by type under "folders":

docs/en/manuals/html5.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ DEFOLD_HEAP_SIZE
191191
DEFOLD_ENGINE_ARGUMENTS
192192
: Engine arguments specified in *game.project* `html5.engine_arguments` separated by `,` symbol.
193193

194+
build-timestamp
195+
: Current build timestamp in seconds.
196+
194197

195198
## Extra parameters
196199

docs/en/manuals/importing-graphics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ Learn more about particle effects in the [Particle fx manual](/manuals/particlef
7070

7171
![gui](images/graphics/gui.png)
7272

73-
Learn more about GUIs in the [GUI manual](/manuals/gui).
73+
Learn more about GUIs in the [GUI manual](/manuals/gui).

0 commit comments

Comments
 (0)