Skip to content

Commit

Permalink
Merge pull request cocos#642 from xunyi0/next
Browse files Browse the repository at this point in the history
sync branch
  • Loading branch information
jareguo authored Oct 9, 2018
2 parents 5d982a2 + 5500019 commit 29067ce
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 18 deletions.
4 changes: 4 additions & 0 deletions en/advanced-topics/i18n.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# i18n multi-language support

> Sorry, i18n multi-language support this part of the content is currently no manpower to maintain and has not been updated for a long time, may not work properly. It is recommended to use dynamic loading to implement multi-language switching function.
The game's multilingual support is implemented through the Cocos Creator editor extension, which implements the multilingual internationalization of the Label and Sprite components (i18n).

Note that the difference between internationalization and localization of multilingualism is that internationalization requires software to include text and image data in multiple languages ​​and to switch in real time based on the default language or menu selection of the device used by the user. Localization is custom text and image content for a specific language when publishing software.
Expand Down Expand Up @@ -88,6 +90,8 @@ I18n.init ('zh'); // languageID should be equal to the one we input in New Langu

You can also call `i18n.init()` when you want to switch languages ​​later.

Then add the `i18n.updateSceneRenderers()` to refresh text in `update()`.

Note that the runtime must ensure that `i18n.init(language)` is executed before the scene containing the LocalizedLabel component is loaded, otherwise it will be errored because the data can not be loaded on the component.

### Script to use the translation key value to get the string
Expand Down
8 changes: 5 additions & 3 deletions en/asset-workflow/auto-atlas.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

## Create an auto-atlas asset

In **Assets** panel right-click on a folder, and click the following context menu item **New -> Auto Atlas**. It will create a **AutoAtlas.pac** asset to hold your atlas configuration for current folder.
In **Assets** panel right-click on a folder, and click the following context menu item **Create -> Auto Atlas**. It will create a **AutoAtlas.pac** asset to hold your atlas configuration for current folder.

! [Create auto atlas](auto-atlas/create-auto-atlas.png)
![create auto atlas](auto-atlas/create-auto-atlas.png)

With an **Auto-atlas asset** created, all **SpriteFrame** assets in the current folder including sub-folders will be used to generate a sprite sheet atlas during build process. And all SpriteFrame assets added to the folder or its sub-folder will be added to the atlas automatically in the future.

Expand All @@ -23,9 +23,11 @@ After selecting an **Auto-atlas asset** in the **Assets** panel, the **Propertie
| Padding | The spacing between sprites in the atlas
| Allow Rotation | Allows rotation of the sprites
| Force Squared | Whether to force the Atlas size to be set to square
| PowerOfTwo | Whether to set the map size to a power of two number
| Power Of Two | Whether to set the map size to a power of two number
| Heuristices | Atlas packaging strategy, the optional strategies are [BestShortSideFit, BestLongSideFit, BestAreaFit, BottomLeftRule, ContactPointRule]
| Format | Image generation format, available in [png, jpg, webp]
| Padding Bleed | Padding with one pixel bleed area for each textures in atlas, the bleed area will copy the nearest pixel in the original texture. This feature is also known as "Extrude".
| Filter Unused Resources | The option will not work in preview process, it only work in build process

After the configuration is complete, you can click the **Preview** button to preview the results of the packaging. The results of the current auto-atlas configuration will be displayed in the area below the **Properties** panel.
Note that after any configuration change, you need to click **Preview** button again to refresh the preview.
Expand Down
Binary file modified en/asset-workflow/auto-atlas/create-auto-atlas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions en/asset-workflow/scene-managing.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Double click the scene that you want to open in **Assets**.

## Change the policy of auto releasing assets from previous scene

In a large game where you have many scenes, as the engine continues to load different scenes, the memory usage will continue to increase. Besides using API such as `cc.loader.release` to accurately release unused assets, we can also use scene's auto releasing feature. To enable auto releasing, select the desired scene in **Assets** panel, then change the "Auto Release Assets" property in **Properties** panel, the property is flase by default.<br>
In a large game where you have many scenes, as the engine continues to load different scenes, the memory usage will continue to increase. Besides using API such as `cc.loader.release` to accurately release unused assets, we can also use scene's auto releasing feature. To enable auto releasing, select the desired scene in **Assets** panel, then change the "Auto Release Assets" property in **Properties** panel, the property is false by default.<br>
When switching from current scene to the next scene, if current scene disabled the auto releasing, then all assets (directly or indirectly) referenced by current scene (except loaded dynamically in scripts) will not release **by default**. On the other hand, if enable the auto releasing, then these assets will release **by default**.

> Known issues: The texture referenced by the plist of the particle system is not automatically released. If you want to automatically release the particle texture, remove the texture information from the plist and use the Texture property of the particle component to assign the texture.
Expand All @@ -38,7 +38,7 @@ The above content of the automatic release of scene resources can be summed up i

## Change the policy of scene loading

Select the scene in **Assets** panel, you will see the "Async Load Assets" property in **Properties** panel, the property is flase by default.
Select the scene in **Assets** panel, you will see the "Async Load Assets" property in **Properties** panel, the property is false by default.

### Disable Async Load Assets

Expand Down
8 changes: 4 additions & 4 deletions en/getting-started/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,21 @@ let dragonDisplay = animNode.addComponent(dragonBones.ArmatureDisplay);
let image = 'http://localhost:7456/res/raw-assets/eee_tex-1529064342.png';
let ske = 'http://localhost:7456/res/raw-assets/eee_ske-1529065642.json';
let atlas = 'http://localhost:7456/res/raw-assets/eee_tex-1529065642.json';
cc.loader.load(image, () => {
cc.loader.load(image, (error, texture) => {
cc.loader.load({ url: atlas, type: 'txt' }, (error, atlasJson) => {
cc.loader.load({ url: ske, type: 'txt' }, (error, dragonBonesJson) => {
let atlas = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = atlasJson;
atlas.texture = image;
atlas.texture = texture;

let asset = new dragonBones.DragonBonesAsset();
asset.dragonBonesJson = dragonBonesJson;

dragonDisplay.dragonAtlasAsset = atlas;
dragonDisplay.dragonAsset = asset;

dragonDisplay.armatureName = 'eee';
dragonDisplay.playAnimation('eee', -1);
dragonDisplay.armatureName = 'box_anim';
dragonDisplay.playAnimation('box_anim', 0);
});
});
});
Expand Down
4 changes: 4 additions & 0 deletions zh/advanced-topics/i18n.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# i18n 游戏多语言支持

> 很抱歉,本文介绍的 i18n 游戏多语言支持这部分内容,目前暂时没有人力维护也很久没有更新了,可能会无法正常运行,建议使用动态加载来自行实现多语言切换功能。
游戏多语言支持是通过 Cocos Creator 编辑器扩展插件实现的,这个插件实现了 Label 和 Sprite 组件的多语言国际化(i18n)。

注意,多语言国际化和本地化的区别是,国际化需要软件里包括多种语言的文本和图片数据,并根据用户所用设备的默认语言或菜单选择来进行实时切换。而本地化是在发布软件时针对某一特定语言的版本定制文本和图片内容。
Expand Down Expand Up @@ -89,6 +91,8 @@ i18n.init('zh'); // languageID should be equal to the one we input in New Langua

需要在之后动态切换语言时也可以调用 `i18n.init()`

然后在 update() 中添加 `i18n.updateSceneRenderers()` 刷新文字。

注意运行时必须保证 `i18n.init(language)` 在包含有 LocalizedLabel 组件的场景加载前执行,否则将会因为组件上无法加载到数据而报错。

### 脚本中使用翻译键值对获取字符串
Expand Down
13 changes: 8 additions & 5 deletions zh/asset-workflow/auto-atlas.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## 创建自动图集资源

**资源管理器** 中右键,可以在如下菜单中找到 **新建 -> 自动图集配置** 的子菜单,点击菜单将会新建一个类似 **AutoAtlas.pac** 的资源。

![create auto atlas](auto-atlas/create-auto-atlas.png)

**自动图集资源** 将会以当前文件夹下的所有 **SpriteFrame** 作为碎图资源,以后会增加其他的选择碎图资源的方式。
Expand All @@ -22,20 +23,22 @@
| 允许旋转 | 是否允许旋转碎图
| 输出大小为正方形 | 是否强制将图集长宽大小设置成正方形
| 输出大小为二次幂 | 是否将图集长宽大小设置为二次方倍数
| 算法 | 图集打包策略, 可选的策略有 [BestShortSideFit, BestLongSideFit, BestAreaFit, BottomLeftRule, ContactPointRule]
| 输出格式 | 图集图片生成格式,可选的格式有 [png, jpg, webp]
| 扩边 | 在碎图的边框为扩展出一像素外框,并复制相邻碎图像素到外框中
| 算法 | 图集打包策略, 可选的策略有 [BestShortSideFitBestLongSideFitBestAreaFitBottomLeftRuleContactPointRule]
| 输出格式 | 图集图片生成格式,可选的格式有 [pngjpgwebp]
| 扩边 | 在碎图的边框外扩展出一像素外框,并复制相邻碎图像素到外框中。该功能也称作 “Extrude”。
| 不包含未被引用资源 | 在预览中,此选项不会生效,构建后此选项才会生效

配置完成后可以点击 **预览** 按钮来预览打包的结果,按照当前自动图集配置生成的相关结果将会展示在 **属性检查器** 下面的区域。
需要注意的是每次配置过后,需要重新点击 **预览** 才会重新生成预览信息。

结果分为:
- Packed Textures, 显示打包后的图集图片以及图片相关的信息,如果会生成的图片有多张,则会往下在 **属性检查器** 中列出来。
- Unpacked Textures显示不能打包进图集的碎图资源,造成的原因有可能是这些碎图资源的大小比图集资源的大小还大导致的,这时候可能需要调整下图集的配置或者碎图的大小了。
- Packed Textures显示打包后的图集图片以及图片相关的信息,如果会生成的图片有多张,则会往下在 **属性检查器** 中列出来。
- Unpacked Textures显示不能打包进图集的碎图资源,造成的原因有可能是这些碎图资源的大小比图集资源的大小还大导致的,这时候可能需要调整下图集的配置或者碎图的大小了。

## 生成图集

预览项目或者在 Cocos Creator 中使用碎图的时候都是直接使用的碎图资源,在 **构建项目** 这一步才会真正生成图集到项目中。

生成的大图将会放在 **构建目录** 下的 **res/raw-assets** 相对于项目中 assets 目录结构下的对应的目录中,以 **AutoAtlas-xx.png** 结构命名。

生成项目后可以到对应的目录下检查对应的图集资源是否生成成功了。
Binary file modified zh/asset-workflow/auto-atlas/create-auto-atlas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions zh/getting-started/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,21 @@ let dragonDisplay = animNode.addComponent(dragonBones.ArmatureDisplay);
let image = 'http://localhost:7456/res/raw-assets/eee_tex-1529064342.png';
let ske = 'http://localhost:7456/res/raw-assets/eee_ske-1529065642.json';
let atlas = 'http://localhost:7456/res/raw-assets/eee_tex-1529065642.json';
cc.loader.load(image, () => {
cc.loader.load(image, (error, texture) => {
cc.loader.load({ url: atlas, type: 'txt' }, (error, atlasJson) => {
cc.loader.load({ url: ske, type: 'txt' }, (error, dragonBonesJson) => {
let atlas = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = atlasJson;
atlas.texture = image;
atlas.texture = texture;

let asset = new dragonBones.DragonBonesAsset();
asset.dragonBonesJson = dragonBonesJson;

dragonDisplay.dragonAtlasAsset = atlas;
dragonDisplay.dragonAsset = asset;

dragonDisplay.armatureName = 'eee';
dragonDisplay.playAnimation('eee', -1);
dragonDisplay.armatureName = 'box_anim';
dragonDisplay.playAnimation('box_anim', 0);
});
});
});
Expand Down

0 comments on commit 29067ce

Please sign in to comment.