瀏覽代碼

A bunch of documentation fixes.

Mikael Säker 8 年之前
父節點
當前提交
c6132bb7fd

二進制
docs/assets/war-battles-assets.zip


+ 0 - 1
docs/en/manuals/bob.md

@@ -1,7 +1,6 @@
 ---
 title: Defold project builder manual
 brief: Bob is a command line tool for building Defold projects. This manual explains how to use the tool.
-
 ---
 
 # Bob the builder

+ 1 - 1
docs/en/manuals/gui-clipping.md

@@ -7,7 +7,7 @@ brief: This manual describes how to create GUI nodes that mask other nodes throu
 
 GUI nodes with textures or text add graphics to the GUI. However, sometimes it is convenient to be able to _mask_ what is being shown, to be able to _remove_ particular parts of the graphics from the screen.
 
-Say, for instance, that you want to create an on-screen HUD element containing a mini-map that the player can use to help orient herself in your game.
+Say, for instance, that you want to create an on-screen HUD element containing a mini-map that players can use to help orient themselves in your game.
 
 ![Minimap HUD](images/clipping/clipping_minimap.png)
 

二進制
docs/en/manuals/images/gui/gui_adjust.png


+ 1 - 1
docs/en/manuals/input.md

@@ -313,7 +313,7 @@ Running this code will result in an input stack ordered like this:
 
 ![Input stack order](images/input/input_stack_order.png)
 
-If the same game object is added more than once to the input stack, the previous entry in the stack will be removed and entries above will be shifted down. The duplicate game object will be placed at the top of the stack. If this happens the engine will issue a warning in the Will probably also add a warning about this in the engine.
+If the same game object is added more than once to the input stack, the previous entry in the stack will be removed and entries above will be shifted down. The duplicate game object will be placed at the top of the stack. If this happens the engine will issue a warning in the console.
 
 ## Consuming input
 

+ 14 - 3
docs/en/manuals/lua.md

@@ -25,7 +25,7 @@ To keep your game working cross platform we suggest you stick to Lua 5.1 feature
 
 ## Syntax
 
-Programs have simple, easy to read syntax. Statements are written one on each line and there is no need to mark the end of a statement. You can optionally use semicolons +;+ to separate statements. Blocks of code are keyword delimited, ending with the `end` keyword. Comments can be either block or until the end of the line:
+Programs have simple, easy to read syntax. Statements are written one on each line and there is no need to mark the end of a statement. You can optionally use semicolons `;` to separate statements. Blocks of code are keyword delimited, ending with the `end` keyword. Comments can be either block or until the end of the line:
 
 ```lua
 --[[
@@ -223,8 +223,14 @@ Arithmetic operators
   print(a * 2 + 3 / 4^5) --> -1.9970703125
   ```
 
+  Lua provides automatic conversions between numbers and strings at run time. Any numeric operation applied to a string tries to convert the string to a number:
+  
+  ```lua
+  print("10" + 1) --> 11
+  ```
+
 Relational/comparison operators
-: `<` (less than), `>` (greater than), `<=` (less or equal), `>=` (greater or equal), `==` (equal), `~=` (not equal). There operators always return `true` or `false`. Values of different types are considered different. If the type is the same, they are compared according to their types. Lua compares tables, userdata, and functions by reference. Two such values are considered equal only if they refer to the same object.
+: `<` (less than), `>` (greater than), `<=` (less or equal), `>=` (greater or equal), `==` (equal), `~=` (not equal). There operators always return `true` or `false`. Values of different types are considered different. If the types are the same, they are compared according to their value. Lua compares tables, userdata, and functions by reference. Two such values are considered equal only if they refer to the same object.
 
   ```lua
   a = 5
@@ -233,6 +239,11 @@ Relational/comparison operators
   if a <= b then
       print("a is less than or equal to b")
   end
+
+  print("A" < "a") --> true
+  print("aa" < "ab") --> true
+  print(10 == "10") --> false
+  print(tostring(10) == "10") --> true
   ```
 
 Logical operators
@@ -688,7 +699,7 @@ Use the value returned from `socket.gettime()` (seconds since system epoch) to b
 Lua's garbage collection runs automatically in the background by default and reclaims memory that the Lua runtime has allocated. Collecting lots of garbage can be a time consuming task so it is good to keep down the number of objects that needs to be garbage collected:
 
 * Local variables are in themselves free and will not generate garbage. (i.e. `local v = 42`)
-* Each _new unique_ string creates a new object. Writing `local s = "some_string"` will create a new object and assign `s` to it. The local +s+ itself will not generate garbage, but the string object will. Using the same string multiple times adds no additional memory cost.
+* Each _new unique_ string creates a new object. Writing `local s = "some_string"` will create a new object and assign `s` to it. The local `s` itself will not generate garbage, but the string object will. Using the same string multiple times adds no additional memory cost.
 * Each time a table constructor is executed (`{ ... }`) a new table is created.
 * Executing a _function statement_ creates a closure object. (i.e. executing the statement `function () ... end`, not calling a defined function)
 * Vararg functions (`function(v, ...) end`) create a table for the ellipsis each time the function is _called_ (in Lua prior to version 5.2, or if not using LuaJIT).

+ 1 - 1
docs/en/manuals/sound.md

@@ -22,7 +22,7 @@ Sound components can only be instanced in-place in a game object. Create a new g
 The created component has a set of properties that should be set:
 
 *Sound*
-: Should be set to a sound file in your project. The file should be in _Wave_ or _Ogg Vorbis_ format (See http://en.wikipedia.org/wiki/WAV and http://en.wikipedia.org/wiki/Vorbis for details).
+: Should be set to a sound file in your project. The file should be in _Wave_ or _Ogg Vorbis_ format with a sampling rate of 44100. (See http://en.wikipedia.org/wiki/WAV and http://en.wikipedia.org/wiki/Vorbis for details).
 
 *Looping*
 : If checked the sound will play back in a loop until explicitly stopped.

+ 1 - 4
docs/en/manuals/texture-profiles.md

@@ -95,7 +95,7 @@ The *formats* added to a profile each have the following properties:
 : Selects the quality level for the resulting compressed image. The values range from `FAST` (low quality, fast compression) to `NORMAL`, `HIGH` and `BEST` (highest quality, slowest compression).
 
 *compression_type*
-: Selects the type of compression used for the resulting compressed image, `COMPRESSION_TYPE_DEFAULT`, `COMPRESSION_TYPE_WEBP` or `COMPRESSION_TYPE_WEBP_LOSSY`. See [Compression Types](#Compression Types) below for more details.
+: Selects the type of compression used for the resulting compressed image, `COMPRESSION_TYPE_DEFAULT`, `COMPRESSION_TYPE_WEBP` or `COMPRESSION_TYPE_WEBP_LOSSY`. See <a href="https://www.defold.com/manuals/texture-profiles/#_compression_types">Compression Types</a> below for more details.
 
 ## Texture formats
 
@@ -147,9 +147,6 @@ ETC
 | Can be compressed on Windows only
 -->
 
-
-<div id="Compression Types"></div>
-
 ## Compression types
 
 The following software image compression types are supported. The data is uncompressed when the texture file is loaded into memory.

二進制
docs/en/tutorials/images/war-battles/main_gui.png


二進制
docs/en/tutorials/images/war-battles/main_ui.png


二進制
docs/en/tutorials/images/war-battles/text_font.png


+ 1 - 1
docs/en/tutorials/magic-link.md

@@ -150,7 +150,7 @@ There are a set of GUI images that are used to create GUI elements, like buttons
 The first step is to build the board logic. The board will reside in its own collection that will contain everything on screen during gameplay. For now, the only thing necessary is the "blockfactory" factory component and the script. Later, we will add a factory for connections, a main menu GUI components and finally loading mechanics to start gameplay from the main menu and a way to exit to the menu.
 
 1. Create *board.collection* in the *main* folder. Make sure to name it "board" so we can address it later. If you add the background sprite component, make sure to set its Z position to -1, or it won't be drawn behind all the blocks we'll spawn later.
-2. Temporarily set *main_collection* in *game.project* to "/main/board.collectionc" so we can easily test.
+2. Temporarily set *Main Collection* (under *Bootstrap*) in *game.project* to "/main/board.collection" so we can easily test.
 
 ![Board collection](images/magic-link/linker_board_collection.png)
 

+ 4 - 3
docs/en/tutorials/shadertoy.md

@@ -44,10 +44,11 @@ Create a new material file *star-nest.material*, a vertex shader program *star-n
 3. Set the *Fragment Program* to `star-nest.fp`.
 4. Add a *Vertex Constant* and name it "view_proj" (for "view projection").
 5. Set its *Type* to `CONSTANT_TYPE_VIEWPROJ`.
+6. Add a tag "tile" to the *Tags*. This is so that the quad is included in the render pass when sprites and tiles are drawn.
 
     ![material](images/shadertoy/material.png)
 
-6. Open the vertex shader program file *star-nest.vp*. It should contain the following code. Leave the code as is.
+7. Open the vertex shader program file *star-nest.vp*. It should contain the following code. Leave the code as is.
 
     ```glsl
     // star-nest.vp
@@ -66,7 +67,7 @@ Create a new material file *star-nest.material*, a vertex shader program *star-n
     }
     ```
 
-7. Open the fragment shader program file *star-nest.fp* and modify the code so the fragment color is set based on the X and Y coordinates of the UV coordinates (`var_texcoord0`). We do this to make sure we have the model set up correctly:
+8. Open the fragment shader program file *star-nest.fp* and modify the code so the fragment color is set based on the X and Y coordinates of the UV coordinates (`var_texcoord0`). We do this to make sure we have the model set up correctly:
 
     ```glsl
     // star-nest.fp
@@ -78,7 +79,7 @@ Create a new material file *star-nest.material*, a vertex shader program *star-n
     }
     ```
 
-8. Set the material on the model component in the "star-nest" game object.
+9. Set the material on the model component in the "star-nest" game object.
 
 Now the editor should render the model with the new shader and we can clearly see if the UV coordinates are correct; the bottom left corner should have black color (0, 0, 0), the top left corner green color (0, 1, 0), the top right corner yellow color (1, 1, 0) and the bottom right corner should have red color (1, 0, 0):
 

+ 17 - 15
docs/en/tutorials/war-battles.md

@@ -294,7 +294,7 @@ end
 13. After the calculations have been made, set the input vector to 0 and unset the `moving` flag.
 14. The `on_input()` function is called every frame for all mapped input that is active. The argument `action_id` contain the action as set up in the input bindings file. The argument `action` is a Lua table with details on the input.
 15. For each input direction, set the X or the Y component of the `input` vector in `self`. If the user presses the <kbd>up arrow</kbd> and <kbd>left arrow</kbd> keys, the engine will call this function twice and the input vector will end up being set to `(-1, 1, 0)`.
-16. If the user presses any of the arrow keys, the input vector length will be non zero. If so, set the `moving` flag so the player will be moved in `update()`. The reason the script does not move the player in the `on_inpup()` function is that it is simpler to collect all input each frame and then act upon it in `update()`.
+16. If the user presses any of the arrow keys, the input vector length will be non zero. If so, set the `moving` flag so the player will be moved in `update()`. The reason the script does not move the player in the `on_input()` function is that it is simpler to collect all input each frame and then act upon it in `update()`.
 17. The `dir` direction vector is set to the normalized value of the input. If the input vector is `(-1, 1, 0)`, for instance, the vector length is greater than 1. Normalizing the vector brings it to a length of exactly 1. Without normalization diagonal movement would be faster than horizontal and vertical. When the engine runs the `update()` function, any user input will have an effect on the `dir` vector which will cause the player to move.
 
 With this piece of Lua code, your game now has a player character that can move around on the screen. Next, let's add the possibility to fire rockets.
@@ -611,35 +611,37 @@ Run the game and destroy some tanks! The tanks aren't very interesting enemies,
 
 ## Scoring GUI
 
-1. Drag the the file *fonts/04B_03.TTF* from the asset pack folder to the *main* folder in the *Assets* view.
+1. Drag the the file *fonts/04font.ttf* from the asset pack folder to the *main* folder in the *Assets* view.
 
 2. <kbd>Right click</kbd> the folder *main* in the *Assets* view and select <kbd>New ▸ Font</kbd>. Name this file *text.font*.
 
+3. Open *text.font* and set the *Font* property to the file *04font.ttf*.
+
     ![text font](images/war-battles/text_font.png)
 
-3. <kbd>Right click</kbd> the folder *main* in the *Assets* view and select <kbd>New ▸ Gui</kbd>. Name this file *ui.gui*. It will contain the user interface where you will place the score counter.
+4. <kbd>Right click</kbd> the folder *main* in the *Assets* view and select <kbd>New ▸ Gui</kbd>. Name this file *ui.gui*. It will contain the user interface where you will place the score counter.
 
-4. Open *ui.gui*. <kbd>Right click</kbd> *Fonts* in the *Outline* view and select <kbd>Add ▸ Fonts</kbd>. Select the */main/text.font* file.
+5. Open *ui.gui*. <kbd>Right click</kbd> *Fonts* in the *Outline* view and select <kbd>Add ▸ Fonts</kbd>. Select the */main/text.font* file.
 
-5. <kbd>Right click</kbd> *Nodes* in the *Outline* view and select <kbd>Add ▸ Text</kbd>.
+6. <kbd>Right click</kbd> *Nodes* in the *Outline* view and select <kbd>Add ▸ Text</kbd>.
 
-6. Select the new text node in the outline and set its *Id* property to "score", its *Text* property to "SCORE: 0", its *Font* property to the font "text" and its *Pivot* property to "West".
+7. Select the new text node in the outline and set its *Id* property to "score", its *Text* property to "SCORE: 0", its *Font* property to the font "text" and its *Pivot* property to "West".
 
-7. Place the text node in the top left corner of the screen.
+8. Place the text node in the top left corner of the screen.
 
     ![ui gui](images/war-battles/ui.png)
 
-8. <kbd>Right click</kbd> the folder *main* in the *Assets* view and select <kbd>New ▸ Gui Script</kbd>. Name this new file "ui.gui_script".
+9. <kbd>Right click</kbd> the folder *main* in the *Assets* view and select <kbd>New ▸ Gui Script</kbd>. Name this new file "ui.gui_script".
 
-9. Go back to *ui.gui* and select the root node in the *Outline*. Set the *Script* property to the file */main/ui.gui_script* that you just created. Now if we add this Gui as a component to a game object the Gui will be displayed and the script will run.
+10. Go back to *ui.gui* and select the root node in the *Outline*. Set the *Script* property to the file */main/ui.gui_script* that you just created. Now if we add this Gui as a component to a game object the Gui will be displayed and the script will run.
 
-10. Open *main.collection*.
+11. Open *main.collection*.
 
-11. <kbd>Right click</kbd> the root node of the collection in the *Outline* and select <kbd>Add Game Object</kbd>.
+12. <kbd>Right click</kbd> the root node of the collection in the *Outline* and select <kbd>Add Game Object</kbd>.
 
-11. Set the *Id* property of the game object to "gui", then <kbd>Right click</kbd> it and select <kbd>Add Component File</kbd>. Select the file */main/ui.gui*.
+13. Set the *Id* property of the game object to "gui", then <kbd>Right click</kbd> it and select <kbd>Add Component File</kbd>. Select the file */main/ui.gui*. The new component will automatically get the *Id* "ui".
 
-    ![main gui](images/war-battles/main_gui.png)
+    ![main gui](images/war-battles/main_ui.png)
 
 Now the score counter is displayed. You only need to add functionality in the Gui script so the score can be updated.
 
@@ -677,11 +679,11 @@ Now the score counter is displayed. You only need to add functionality in the Gu
         elseif message_id == hash("collision_response") then
             explode(self)
             go.delete(message.other_id)
-            msg.post("/gui#gui", "add_score", {score = 100}) -- <1>
+            msg.post("/gui#ui", "add_score", {score = 100}) -- <1>
         end
     end
     ```
-    1. Post a message named "add_score" to the component "gui" in the game object named "gui" at the root of the main collection. Pass along a table where the field `score` has been set to 100.
+    1. Post a message named "add_score" to the component "ui" in the game object named "gui" at the root of the main collection. Pass along a table where the field `score` has been set to 100.
 
 4. Try the game!