瀏覽代碼

Fixes according users feedback (#38)

* Runner tuttorial fixed

* Updated car tutorial

* fix typos

* Gui layouts

* Update Reactive logic example

* Added model for the tutorial
Alexey Gulev 6 年之前
父節點
當前提交
5f1ba480cb

二進制
docs/assets/quad.dae.zip


+ 1 - 1
docs/en/manuals/building-blocks.md

@@ -48,7 +48,7 @@ A collection is always added to another collection as a reference to a collectio
 
 ## Game objects
 
-Game objects are simple objects that each have a separate lifespan during the execution of your game. Game objects have a position, rotation and scale that each can be manipulated and animated at runtime.
+Game objects are simple objects that each have a separate lifespan during the execution of your game. Game objects have a position, rotation, and scale that each of which can be manipulated and animatied at runtime.
 
 ```lua
 -- animate X position of "can" game object

+ 4 - 0
docs/en/manuals/glossary.md

@@ -51,6 +51,10 @@ Components are used to give specific expression and/or functionality to game obj
 
 At some point your game will behave in an unexpected way and you need to figure out what is wrong. Learning how to debug is an art and fortunately Defold ships with a built in debugger to help you out. See the [Debugging manual](/manuals/debugging) for more information.
 
+## Display profiles
+
+![Display profiles](images/icons/display-profiles.png){.left} The display profiles resource file is used for specifying GUI layouts depends on the orientation, aspect ratio or device model. It helps to adapt your UI for any kind of devices. Read more in the [Layouts manual](/manuals/gui-layouts).
+
 ## Factory
 
 ![Factory](images/icons/factory.png){.left} In some situations you cannot manually place all needed game objects in a collection, you have to create the game objects dynamically, on the fly. For instance, a player might fire bullets and each shot should be dynamically spawned and sent off whenever the player presses the trigger. To create game objects dynamically (from a pre-allocated pool of objects), you use a factory component. See the [Factory manual](/manuals/factory) for details.

二進制
docs/en/manuals/images/icons/display-profiles.png


+ 47 - 51
docs/en/manuals/lua.md

@@ -64,11 +64,11 @@ boolean
   else
       print("flag is false")
   end
-  
+
   if my_var then
       print("my_var is not nil nor false!")
   end
-  
+
   if not my_var then
       print("my_var is either nil or false!")
   end
@@ -81,7 +81,7 @@ number
   print(10) --> prints '10'
   print(10.0) --> '10'
   print(10.000000000001) --> '10.000000000001'
-  
+
   a = 5 -- integer
   b = 7/3 -- float
   print(a - b) --> '2.6666666666667'
@@ -112,16 +112,16 @@ string
   my_string = "hello"
   another_string = 'world'
   print(my_string .. another_string) --> "helloworld"
-  
+
   print("10.2" + 1) --> 11.2
   print(my_string + 1) -- error, can't convert "hello"
   print(my_string .. 1) --> "hello1"
-  
+
   print("one\nstring") --> one
                        --> string
-  
+
   print("\097bc") --> "abc"
-  
+
   multi_line_string = [[
   Here is a chunk of text that runs over several lines. This is all
   put into the string and is sometimes very handy.
@@ -136,31 +136,31 @@ function
   my_plus = function(p, q)
       return p + q
   end
-  
+
   print(my_plus(4, 5)) --> 9
-  
+
   -- Convenient syntax to assign function to variable 'my_mult'
   function my_mult(p, q)
       return p * q
   end
-  
+
   print(my_mult(4, 5)) --> 20
-  
+
   -- Takes a function as parameter 'func'
   function operate(func, p, q)
       return func(p, q) -- Calls the provided function with parameters 'p' and 'q'
   end
-  
+
   print(operate(my_plus, 4, 5)) --> 9
   print(operate(my_mult, 4, 5)) --> 20
-  
+
   -- Create an adder function and return it
   function create_adder(n)
       return function(a)
           return a + n
       end
   end
-  
+
   adder = create_adder(2)
   print(adder(3)) --> 5
   print(adder(10)) --> 12
@@ -175,19 +175,19 @@ table
               "Thursday", "Friday", "Saturday"}
   print(weekdays[1]) --> "Sunday"
   print(weekdays[5]) --> "Thursday"
-  
+
   -- Initialize a table as a record with sequence values
-  moons = { Earth = { "Moon" }, 
+  moons = { Earth = { "Moon" },
             Uranus = { "Puck", "Miranda", "Ariel", "Umbriel", "Titania", "Oberon" } }
   print(moons.Uranus[3]) --> "Ariel"
-  
+
   -- Build a table from an empty constructor {}
   a = 1
   t = {}
   t[1] = "first"
   t[a + 1] = "second"
   t.x = 1 -- same as t["x"] = 1
-  
+
   -- Iterate over the table key, value pairs
   for key, value in pairs(t) do
       print(key, value)
@@ -195,10 +195,10 @@ table
   --> 1   first
   --> 2   second
   --> x   1
-  
+
   u = t -- u now refers to the same table as t
   u[1] = "changed"
-  
+
   for key, value in pairs(t) do -- still iterating over t!
       print(key, value)
   end
@@ -224,7 +224,7 @@ Arithmetic operators
   ```
 
   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
   ```
@@ -235,7 +235,7 @@ Relational/comparison operators
   ```lua
   a = 5
   b = 6
-  
+
   if a <= b then
       print("a is less than or equal to b")
   end
@@ -253,7 +253,7 @@ Logical operators
   print(true or false) --> true
   print(true and false) --> false
   print(not false) --> true
-  
+
   if a == 5 and b == 6 then
       print("a is 5 and b is 6")
   end
@@ -273,13 +273,13 @@ Length
   ```lua
   s = "donkey"
   print(#s) --> 6
-  
+
   t = { "a", "b", "c", "d" }
   print(#t) --> 4
-  
+
   u = { a = 1, b = 2, c = 3 }
   print(#u) --> 0
-  
+
   v = { "a", "b", nil }
   print(#v) --> 2
   ```
@@ -294,11 +294,11 @@ if---then---else
   ```lua
   a = 5
   b = 4
-  
+
   if a < b then
       print("a is smaller than b")
   end
-  
+
   if a == '1' then
       print("a is 1")
   elseif a == '2' then
@@ -316,7 +316,7 @@ while
   ```lua
   weekdays = {"Sunday", "Monday", "Tuesday", "Wednesday",
               "Thursday", "Friday", "Saturday"}
-  
+
   -- Print each weekday
   i = 1
   while weekdays[i] do
@@ -331,7 +331,7 @@ repeat---until
   ```lua
   weekdays = {"Sunday", "Monday", "Tuesday", "Wednesday",
               "Thursday", "Friday", "Saturday"}
-  
+
   -- Print each weekday
   i = 0
   repeat
@@ -348,17 +348,17 @@ for
   for i = 1, 10 do
       print(i)
   end
-  
+
   -- Print the numbers 1 to 10 and increment with 2 each time
   for i = 1, 10, 2 do
       print(i)
   end
-  
+
   -- Print the numbers 10 to 1
   for i=10, 1, -1 do
       print(i)
   end
-  
+
   t = { "a", "b", "c", "d" }
   -- Iterate over the sequence and print the values
   for i, v in ipairs(t) do
@@ -377,11 +377,11 @@ break and return
           break
       end
   end
-  
+
   function my_add(a, b)
       return a + b
   end
-  
+
   print(my_add(10, 12)) --> 22
   ```
 
@@ -613,31 +613,27 @@ function on_message(self, message_id, message, sender)
 end
 ```
 
-Even in this quite simple case we get fairly tangled up logic. It's possible to make this look better with the help of coroutines in a module (see below), but let's instead try to make this reactive and use a built in timing mechanism: property animation.
+Even in this quite simple case we get fairly tangled up logic. It's possible to make this look better with the help of coroutines in a module (see below), but let's instead try to make this reactive and use a built in timing mechanism.
 
 ```lua
--- Dummy property only for timing
-go.property("dummy", 0)
-function init(self)
-    -- Wait 2s then call send_first()
-    go.animate("#", "dummy", go.PLAYBACK_ONCE_FORWARD, 0,
-                 go.EASING_LINEAR, 2.0, 0, send_first)
+local function send_first()
+	msg.post("some_object", "some_message")
 end
 
-function send_first()
-    msg.post("some_object", "some_message")
+function init(self)
+	-- Wait 2s then call send_first()
+	timer.delay(2, false, send_first)
 end
 
-function send_second()
-    msg.post("another_object", "another_message")
+local function send_second()
+	msg.post("another_object", "another_message")
 end
 
 function on_message(self, message_id, message, sender)
-    if message_id == hash("response") then
-        -- Wait 5s then call send_second()
-        go.animate("#", "dummy", go.PLAYBACK_ONCE_FORWARD, 0,
-                    go.EASING_LINEAR, 5.0, 0, send_second)
-    end
+	if message_id == hash("response") then
+		-- Wait 5s then call send_second()
+		timer.delay(5, false, send_second)
+	end
 end
 ```
 

+ 1 - 1
docs/en/tutorials/car.md

@@ -71,7 +71,7 @@ Click on the *main* folder in the *Project Explorer*, then right-click and selec
 
 Name the new collection file *car.collection* and open it. We're going to use this new, empty collection to build a small car out of a couple of game objects. A game object is a container of components (like sprites, sounds, logic scripts etc) that you use to build your game. Each game object is uniquely identified in the game by its id. Game objects can communicate with each other through message passing, but more on that later.
 
-You can create a game object _in place_ in a collection, like we did here. That results in a one-of a kind object. You can copy that object but each copy is separate---changing one does not affect the others. This means that if you create 10 copies of a game object and realize that you want to change them all, you will need to edit all 10 instances of the object. Therefore, in place created game objects should be used for objects that you do not intend to make a lot of copies of.
+Also, it's possible to create a game object in place in a collection, as we did here. That results in a one-of-a-kind object. You can copy that object but each copy is separate---changing one does not affect the others. This means that if you create 10 copies of a game object and realize that you want to change them all, you will need to edit all 10 instances of the object. Therefore, in place created game objects should be used for objects that you do not intend to make a lot of copies of.
 
 However, a game object that is stored in a _file_ works as a blueprint. When you place instances of a file stored game object in a collection each object is placed _by reference_---it is a clone based on the blueprint. If you decide you need to change the blueprint, every single placed game object based on that blueprint is instantly updated.
 

+ 2 - 2
docs/en/tutorials/runner.md

@@ -135,7 +135,7 @@ That's it!
 The Defold editor works on files. By double-clicking a file in the *Project Explorer* you open it in a suitable editor. You can then work with the contents of the file.
 
 When you are done editing a file you have to save it. Select <kbd>File ▸ Save</kbd> in the main menu. The editor gives a hint by adding an asterisk '\*' to the filename in the tab for any file that contain unsaved changes.
-  
+
 ![File with unsaved changes](images/runner/1/file_changed.png)
 :::
 
@@ -169,7 +169,7 @@ Let's take the first baby steps and create an arena for our character, or rather
 
 4. Create a collection file *ground.collection* for the ground and add 7 game objects to it (right-click the root of the collection in the *Outline* view and select <kbd>Add Game Object</kbd>). Name the objects "ground0", "ground1", "ground2" etc by changing the *Id* property in the *Properties* view. Note that Defold automatically assigns new game objects a unique id.
 
-5. In each object, add a sprite component (right-click the game object in the *Outline* view and select <kbd>Add Component</kbd>, then select *Sprite* and click *OK*), set the *Image* property of the sprite component to the atlas you just created and set the default animation of the sprite to one of the two ground images. Set the X position of the _sprite component_ (not the game object) to 190. Since the width of the image is 380 pixels and we shift it sideways half as many pixels, the pivot of the game object will be at the leftmost edge of the sprite image.
+5. In each object, add a sprite component (right-click the game object in the *Outline* view and select <kbd>Add Component</kbd>, then select *Sprite* and click *OK*), set the *Image* property of the sprite component to the atlas you just created and set the default animation of the sprite to one of the two ground images. Set the X position of the _sprite component_ (not the game object) to 190 and Y position to 40. Since the width of the image is 380 pixels and we shift it sideways half as many pixels, the pivot of the game object will be at the leftmost edge of the sprite image.
 
   ![Create ground collection](images/runner/1/ground_collection.png)
 

+ 14 - 10
docs/en/tutorials/shadertoy.md

@@ -19,6 +19,10 @@ The Star Nest shader is a pure fragment shader, so we only need something for th
 
 We start by creating a quadratic plane mesh in Blender (or any other 3D modelling program). For convenience the 4 vertex coordinates are at -1 and 1 on the X-axis and -1 and 1 on the Y axis. Blender has the Z-axis up by default so you need to rotate the mesh 90° around the X-axis. You should also make sure that you generate correct UV-coordinates for the mesh. In Blender, enter *Edit Mode* with the mesh selected, then select <kbd>Mesh ▸ UV unwrap... ▸ Unwrap</kbd>.
 
+
+<a class="btn btn-primary btn-xs-block btn-icon" href="//storage.googleapis.com/defold-doc/assets/quad.dae.zip">Download quad.dae<span aria-hidden="true" class="icon icon-download"></span></a>
+
+
 ::: sidenote
 Blender is a free, open-source 3D software which can be downloaded from [blender.org](https://www.blender.org).
 :::
@@ -53,13 +57,13 @@ Create a new material file *star-nest.material*, a vertex shader program *star-n
     ```glsl
     // star-nest.vp
     uniform mediump mat4 view_proj;
-    
+
     // positions are in world space
     attribute mediump vec4 position;
     attribute mediump vec2 texcoord0;
-    
+
     varying mediump vec2 var_texcoord0;
-    
+
     void main()
     {
         gl_Position = view_proj * vec4(position.xyz, 1.0);
@@ -72,7 +76,7 @@ Create a new material file *star-nest.material*, a vertex shader program *star-n
     ```glsl
     // star-nest.fp
     varying mediump vec2 var_texcoord0;
-    
+
     void main()
     {
         gl_FragColor = vec4(var_texcoord0.xy, 0.0, 1.0);
@@ -98,7 +102,7 @@ Now everything is in place to start working on the actual shader code. Let's fir
     In Defold, the input texture coordinates are passed from the vertex shader as UV coordinates (in the range 0--1) through a varying variable `var_texcoord0`. The output fragment color is set to the built in variable `gl_FragColor`.
 
 3. Lines 23--27 sets up the dimensions of the texture as well as movement direction and scaled time. The resolution of the viewport/texture is passed to the shader as `uniform vec3 iResolution`. The shader calculates UV style coordinates with the right aspect ratio from the fragment coordinates and the resolution. Some resolution offsetting is also done to get a nicer framing.
-    
+
     The Defold version needs to alter these calculations to use the UV coordinates from `var_texcoord0`.
 
     Time is also set up here. It is passed to the shader as `uniform float iGlobalTime`. Defold does not currently support `float` uniforms so we need to provide time through a `vec4` instead.
@@ -140,7 +144,7 @@ void main() // <2>
     vec2 res = vec2(1.0, 1.0); // <3>
     vec2 uv = var_texcoord0.xy * res.xy - 0.5;
     vec3 dir = vec3(uv * zoom, 1.0);
-    float time = 0.0; // <4> 
+    float time = 0.0; // <4>
 
     float a1=0.5; // <5>
     float a2=0.8;
@@ -152,7 +156,7 @@ void main() // <2>
     from += vec3(time * 2.0, time, -2.0);
     from.xz *= rot1;
     from.xy *= rot2;
-    
+
     //volumetric rendering
     float s = 0.1, fade = 1.0;
     vec3 v = vec3(0.0);
@@ -161,7 +165,7 @@ void main() // <2>
         // tiling fold
         p = abs(vec3(tile) - mod(p, vec3(tile * 2.0)));
         float pa, a = pa = 0.0;
-        for (int i=0; i < iterations; i++) { 
+        for (int i=0; i < iterations; i++) {
             // the magic formula
             p = abs(p) / dot(p, p) - formuparam;
             // absolute sum of average change
@@ -176,7 +180,7 @@ void main() // <2>
         v += fade;
         // coloring based on distance
         v += vec3(s, s * s, s * s * s * s) * a * brightness * fade;
-        fade *= distfading; 
+        fade *= distfading;
         s += stepsize;
     }
     // color adjust
@@ -282,4 +286,4 @@ You can view the results here:
 
 A fun continuation exercise is to add the original mouse movement input to the shader. It should be fairly straightforward if you grasp how to deal with input.
 
-Happy Defolding!
+Happy Defolding!