Browse Source

Dynamic prototype part of the collection factory. (#351)

* update physics

* update input

* update

* update code sharing in getting-help.md

* Export Compliance

* update on file i/o

* pi / 4

* inputs

* forum url

* read only user

* html5 gamepad

* sdk api update

* update

* image properties

* update editor

* defold sdk update

* animation updates

* animation fix

* run as admin

* update bob

* update about AndroidX support

* software render

* linux-faq.md update

* 4.28.2021 updates

* Basis Universal format

* sound & mesh

* gamepad event mapping

* admob url

* Minor edit to building blocks intro text

* update gamepad & ios

* project settings

* libffi version

* scaling

* image compression

* update gamepads

* increase memory

* caching assets

* update 2021/10/6

* update 2021/10/16
blend-modes.md

* update 2021/11/12

* allow dynamic transforms update

* Bundle update

* update faq

* bullet & bob

* script properties update

* editor-styling

* build server url

* editor templates

* spine extension update

* Fix typo in the "optimizations" word in Chinese docs

* Update to material.md - Constants buffers

* Verify Graphics Calls

* H5 parameters

* OpenJDK downloads

* cn update corresponds to [pull 259](https://github.com/defold/doc/pull/259)

* application security

* porting guidelines

* update for 8f1651f

* cn update for 094bf6f

* cn update for 20fdfc5 & 6263317

* cn update for 7/19/2022

* title

* profiling update

* update editor.md

* update bob.md

* update shortcuts

* update fixed update note

* Update properties.md

* Update material.md

* Updates links

* Update bob help with the latest info

* camera & renderer

* Updated android keystore info zh_cn

* bundling.md release vs debug zh_cn

* update bob.md & gui-clipping.md

* contentless bundle

* consoles update

* model animation link

* gamepad & faq

* remove a camera lib

* font shadow render mode fix

* updates about app-manifest and others

* Update script.md

* includes in shaders

* editor scripts

* material updates

* Added dynamic atlas and texture creation

* fixes for atlas and some others

* update screenshots and add explanations (CN)

* add a line about Dynamic Prototype (CN)

* remove "inline" marks in pics

* de-translate the subtitle "Running the debugger" & images fix

* bundle identifier restrictions

* node properties Enabled and Visible (CN)

* release checklist & slice-9

* Update project-settings.md (CN)

* Update camera.md (CN)

* Update project-settings.md (CN)

* culling of meshes (CN)

* Update project-settings.md (CN)

* gltf model file support (CN)

* updates about factory (CN)

* Update bob.md (CN)

* Update bob.jar help (CN)

* Update about renderer and other things

* Update PS4 development and other things

* Dynamic prototype part of the collection factory.

* sync to atlas.md
COCO 1 năm trước cách đây
mục cha
commit
ca8ad8e675

+ 5 - 4
docs/zh/faq/faq.md

@@ -70,13 +70,14 @@ brief: 有关 Defold 游戏引擎和编辑器及平台的常见问题和解答.
 
 #### 问: Defold 能输出哪些平台的游戏?
 
-答: 可以一键发布 任天堂 Switch, iOS, Android 和 HTML5 游戏, 外加 macOS, Windows 和 Linux 游戏. 真正的一套代码平台通用.
+答: 可以一键发布到 PS4™, 任天堂 Switch, iOS, Android 和 HTML5 游戏, 外加 macOS, Windows 和 Linux 游戏. 真正的一套代码平台通用.
 
 
 #### 问: Defold 基于何种渲染引擎?
 
-A: Defold 在 HTML5 中使用 WebGL, iOS 和 macOS 中使用 Metal, 其他平臺中使用 Vulkan 或者 OpenGL ES 2.0. 作爲開發者只需要關心可編程渲染管綫所支持的一種渲染 API 即可.
+A: 作爲開發者只需要關心可編程渲染管綫所支持的一種渲染 API [完全可程式化渲染管线](/manuals/render/). Defold 渲染脚本 API 会把渲染操作转换为如下图形 API:
 
+:[图形 API](../shared/graphics-api.md)
 
 #### 问: 如何获取 Defold 版本信息?
 
@@ -137,12 +138,12 @@ A: Defold 在 HTML5 中使用 WebGL, iOS 和 macOS 中使用 Metal, 其他平臺
 
 ## Defold 报错
 
-
 #### 问: 游戏无法启动也没有报错. 怎么办?
 
 答: 如果二次编译不通过很肯能由你最后做的改动导致. 从菜单栏选择 *Project > Rebuild And Launch* 试试.
 
 
+
 ## 游戏内容相关
 
 #### 问: Defold 里有 prefab 吗?
@@ -174,7 +175,7 @@ A: 精灵默认着色程序包含 "tint" 属性:
   local green = 0.3
   local blue = 0.55
   local alpha = 1
-  sprite.set_constant("#sprite", "tint", vmath.vector4(red, green, blue, alpha))
+  go.set("#sprite", "tint", vmath.vector4(red, green, blue, alpha))
   ```
 
 

+ 19 - 19
docs/zh/manuals/addressing.md

@@ -137,27 +137,27 @@ Defold 提供两种简化写法用来简化消息传递时需要输入的完整
 
 ## 绝对地址
 
-定位的时候完全可以使用绝对地址. 多数情况下相对地址有助于代码重用, 但是有些情况下还得使用绝对地址定位.
+定位的时候完全可以使用上述完整的标记. 多数情况下相对地址有助于代码重用, 但是有些情况下还得使用绝对地址定位.
 
 比如, 你需要一个 AI 管理器管理每个豆子先生. 豆子先生要向管理器报告自身的激活状态, 管理器根据它们的状态决定它们的排序. 这就需要创建一个带脚本的管理器对象然后把它放在引导启动集合的根目录下.
 
 ![manager object](images/addressing/manager_editor.png)
 
-Each bean is then responsible for sending status messages to the manager: "contact" if it spots an enemy or "ouch!" if it is hit and takes damage. For this to work, the bean controller scrips use absolute addressing to send messages to the component "controller" in "manager".
+然后每个豆子先生负责向管理器发送状态消息: "contact" 表明碰到了敌人, 或者 "ouch!" 表明受到了袭击. 为了这项工作, 豆子控制器脚本使用相对地址向 "manager" 里的 "controller" 组件发送消息.
 
-Any address that starts with a '/' will be resolved from the root of the game world. This corresponds to the root of the *bootstrap collection* that is loaded on game start.
+任何以 '/' 开头的地址都从游戏世界的根上进行索引. 这对应了游戏启动时载入的 *bootstrap collection* 的根.
 
-The absolute address of the manager script is `"/manager#controller"` and this absolute address will resolve to the right component no matter where it is used.
+控制器脚本的绝对地址是`"/manager#controller"` 而且不管组件用在哪里该绝对地址总能定位到该组件.
 
 ![teams and manager](images/addressing/teams_manager.png)
 
 ![absolute addressing](images/addressing/absolute.png)
 
-## Hashed identifiers
+## 哈希标记
 
-The engine stores all identifiers as hashed values. All functions that take as argument a component or a game object accepts a string, hash or an URL object. We have seen how to use strings for addressing above.
+引擎把每个标记都存为哈希值. 所有以组件或游戏对象为参数的方法可以接受字符串, 哈希或者 URL 对象. 我们已经在上面看到如何使用字符串进行定位了.
 
-When you get the identifier of a game object, the engine will always return an absolute path identifier that is hashed:
+当你获取游戏对象的标记, 引擎总是返回一个绝对路径标记的哈希值:
 
 ```lua
 local my_id = go.get_id()
@@ -167,10 +167,10 @@ local spawned_id = factory.create("#some_factory")
 print(spawned_id) --> hash: [/instance42]
 ```
 
-You can use such an identifier in place of a string id, or construct one yourself. Note though that a hashed id corresponds to the path to the object, i.e. an absolute address:
+你可以用该标记代替字符串 id, 或者自己写一个. 注意虽然哈希化 id 对应了对象的路径, 比如绝对地址:
 
 ::: sidenote
-The reason relative addresses must be given as strings is because the engine will compute a new hash id based on the hash state of the current naming context (collection) with the given string added to the hash.
+相对地址必须作为字符串使用因为引擎会基于当前命名上下文(集合)的哈希状态, 把字符串添加到哈希后面, 计算出新的哈希id.
 :::
 
 ```lua
@@ -188,30 +188,30 @@ go.set_position(pos, relative_id)
 
 ## URLs
 
-To complete the picture, let's look at the full format of Defold addresses: the URL.
+最后我们来看 Defold 定位的完全体: URL.
 
-An URL is an object, usually written as specially formatted strings. A generic URL consists of three parts:
+URL 是一个对象, 通常用特定格式的字符串表示. 一般一个 URL 包含三个部分:
 
 `[socket:][path][#fragment]`
 
 socket
-: Identifies the game world of the target. This is important when working with [Collection Proxies](/manuals/collection-proxy) and is then used to identify the _dynamically loaded collection_.
+: 代表目标的游戏世界. 使用 [集合代理](/manuals/collection-proxy) 时, 它用来表示 _动态加载的集合_.
 
 path
-: This part of the URL contains the full id of the target game object.
+: 该部分包含目标游戏对象的完整 id.
 
 fragment
-: The identity of the target component within the specified game object.
+: 标志了指定游戏对象内的目标组件.
 
-As we have seen above, you can leave out some, or most of this information in the majority of cases. You almost never need to specify the socket, and you often, but not always, have to specify the path. In those cases when you do need to address things in another game world then you need to specify the socket part of the URL. For instance, the full URL string for the "controller" script in the "manager" game object above is:
+上面已经看到, 你可以省略一些, 或者大多数情况下省略许多部分. 几乎可以不用到 socket, 经常, 不是所有情况下, 需要指定路径. 需要定位其他游戏世界里的东西的情况下需要指定 URL 的 socket 部分. 例如,  上述 "manager" 游戏对象里的 "controller" 脚本的完整 URL 字符串为:
 
 `"main:/manager#controller"`
 
-and the buddy controller in team_2 is:
+然后 team_2 里的 buddy 控制器为:
 
 `"main:/team_2/buddy#controller"`
 
-We can send messages to them:
+我们可以向它们发送消息:
 
 ```lua
 -- Send "hello" to the manager script and team buddy bean
@@ -219,9 +219,9 @@ msg.post("main:/manager#controller", "hello_manager")
 msg.post("main:/team_2/buddy#controller", "hello_buddy")
 ```
 
-## Constructing URL objects
+## 构建 URL 对象
 
-URL objects can also be constructed programmatically in Lua code:
+URL 对象也可以使用 Lua 代码构建:
 
 ```lua
 -- Construct URL object from a string:

+ 10 - 5
docs/zh/manuals/android.md

@@ -69,7 +69,15 @@ $ adb install Defold\ examples.apk
 Success
 ```
 
-#### Installing an AAB
+#### 使用编辑器安装 APK
+
+你可以在编辑器的打包对话框中勾选 "Install on connected device" 和 "Launch installed app"  安装并启动 *.apk*:
+
+![Install and Launch APK](images/android/install_and_launch.png)
+
+为了顺利运行, 你要安装好 ADB 并打开连接设备的 *USB debugging*. 如果编辑器无法找到 ADB 命令行工具的地址, 你要在 [Preferences](/manuals/editor-preferences/#tools) 中指定好.
+
+#### 安装 AAB
 
 对于 *.aab* 文件可以通过 [Google Play 开发者控制台](https://play.google.com/apps/publish/) 上传给 Google Play. 也可以使用 *.aab* 文件制作 *.apk* 以便使用 [Android 打包工具](https://developer.android.com/studio/command-line/bundletool) 在本地安装.
 
@@ -80,15 +88,12 @@ Defold 引擎需要一些权限来运行各种功能. 权限在 `AndroidManifest
 ### android.permission.INTERNET and android.permission.ACCESS_NETWORK_STATE (Protection level: normal)
 允许应用打开网络连接访问互联网. 需要上网时需要此权限. 见 ([Android 官方文档-网络](https://developer.android.com/reference/android/Manifest.permission#INTERNET)) 和 ([Android 官方文档-网络状态](https://developer.android.com/reference/android/Manifest.permission#ACCESS_NETWORK_STATE)).
 
-### android.permission.WRITE_EXTERNAL_STORAGE (Protection level: dangerous)
-允许应用写入外部存储器. 从 API level 19 开始, 读写 Context.getExternalFilesDir(String) 和 Context.getExternalCacheDir() 返回的应用目录不需要此权限. 需要 (使用 io.* 或 sys.save/load) 读写 [sys.get_save_file()](/ref/sys/#sys.get_save_file:application_id-file_name) 之外的目录文件以及 Android manifest 里设置 `android:minSdkVersion` 小于 19 时需要此权限. ([[Android 官方文档-外存写入](https://developer.android.com/reference/android/Manifest.permission#WRITE_EXTERNAL_STORAGE)).
-
 ### android.permission.WAKE_LOCK (Protection level: normal)
 允许应用阻止屏幕息屏和调光. 接收通知保持亮屏时需要此权限. ([[Android 官方文档-亮屏锁定](https://developer.android.com/reference/android/Manifest.permission#WAKE_LOCK))
 
 
 ## 使用 AndroidX
-AndroidX 一個較大改動就是, 不再維護 Android Support Library 了. AndroidX 應用使用雲計算功能和新庫完整取代了 Support Library. [Asset Portal](/assets) 裏的绝大多数擴展包已經支持 AndroidX. 如果希望使用旧版安卓库而不是 AndroidX, 可以在 Defold Manifest 文件里勾選 "Use Android Support lib" 選項.
+AndroidX 一個較大改動就是, 不再維護 Android Support Library 了. AndroidX 應用使用雲計算功能和新庫完整取代了 Support Library. [Asset Portal](/assets) 裏的绝大多数擴展包已經支持 AndroidX. 如果希望使用旧版安卓库而不是 AndroidX, 可以创建新的 app manifest 文件或在 Defold Manifest 文件里勾選 "Use Android Support lib" 選項.
 
 ![](images/android/enable_supportlibrary.png)
 

+ 5 - 0
docs/zh/manuals/animation.md

@@ -10,3 +10,8 @@ Defold 内置组件支持多种动画:
 * [逐帧动画](/manuals/flipbook-animation) - 按顺序显示图片而形成的动画
 * [3D 模型动画](/manuals/model-animation) - 3D 蒙皮动画
 * [属性动画](/manuals/property-animation) - 以position, scale, rotation 等属性插值变换而形成的动画
+
+其他动画格式要使用扩展支持:
+
+* [Rive animation](/extension-rive) - 播放基于矢量的 2D 骨骼动画
+* [Spine animation](/extension-spine) - 播放贴图 2D 骨骼动画

+ 10 - 0
docs/zh/manuals/atlas.md

@@ -66,6 +66,15 @@ Inner Padding
 Extrude Borders
 : 每个图片四周的边缘挤出. 片元着色器采样图片边缘的时候, 相邻图片 (同个图集) 边缘可能会被采集到. 挤出边缘就可以解决这个问题.
 
+Max Page Size
+: 多页图集的最大尺寸. 可以用来把一个图集切分成多页来限制图集尺寸以便只用一个 draw call. 它必须与`/builtins/materials/*_paged_atlas.material` 里开启 multi-page atlas enabled materials 一起使用.
+
+![Multi-page atlas](images/atlas/multipage_atlas.png)
+
+Rename Patterns
+: 以逗号 (´,´) 分隔的搜索和替换用的表达式列表, 每个表达式的形式为 `search=replace`.
+图片的原始名字 (文件名) 会用这些表达式改变. (比如 表达式 `hat=cat,_normal=`, 会重命名 `hat_normal` 为 `cat`). 这在多图集间匹配动画时很有用.
+
 这里用四个 64x64 正方形图片做图集不同属性设置的演示. 注意这里图集一旦超过 128x128 就会跳到 256x256, 从而造成了资源浪费.
 
 ![Atlas properties](images/atlas/atlas_properties.png){srcset="images/atlas/[email protected] 2x"}
@@ -149,6 +158,7 @@ Playback
           stream[index + 3] = 0xFF
       end
   end
+
   local params = { width=width, height=height, x=0, y=0, type=resource.TEXTURE_TYPE_2D, format=resource.TEXTURE_FORMAT_RGBA, num_mip_maps=1 }
   resource.set_texture(my_texture_id, params, buf)
 ```

+ 20 - 0
docs/zh/manuals/collection-factory.md

@@ -148,3 +148,23 @@ end
       collectionfactory.unload("#factory")
   end
   ```
+
+
+## 动态 prototype
+
+可以通过点选集合工厂的 *Dynamic Prototype* 选项来更改它的 *Prototype*.
+
+![动态 prototype](images/collection_factory/dynamic_prototype.png)
+
+当 *Dynamic Prototype* 选项被选中, 则集合工厂组件就可使用 `collectionfactory.set_prototype()` 函数更改其原型. 例如:
+
+```lua
+collectionfactory.unload("#factory") -- 卸载之前的资源
+collectionfactory.set_prototype("#factory", "/main/levels/level1.collectionc")
+local ids = collectionfactory.create("#factory")
+```
+
+::: important
+当 *Dynamic Prototype* 被选中, 集合组件数优化则不可使用, 宿主集合将使用 *game.project* 文件中定义的默认最大组件数目.
+:::
+

+ 8 - 0
docs/zh/shared/graphics-api.md

@@ -0,0 +1,8 @@
+| System   | Graphics API               | Note                     |
+|----------|----------------------------|--------------------------|
+| macOS    | Metal (via MoltenVK)       |                          |
+| Windows  | OpenGL 3.1 or Vulkan 1.1   |                          |
+| Linux    | OpenGL 3.1 or Vulkan 1.1   |                          |
+| Android  | OpenGLES 3.0 or Vulkan 1.1 | Fallback to OpenGLES 2.0 |
+| iOS      | Metal (via MoltenVK)       |                          |
+| HTML5    | WebGL 2.0                  | Fallback to WebGL 1.0    |