Skip to content

Commit

Permalink
sprite multiple textures (#384)
Browse files Browse the repository at this point in the history
* 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](#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

* sync to design.md

* sync to gpgs.md

* sync to hot-reload.md

* sync to linux.md

* sync to live-update.md

* sync to lua.md

* sync to networking.md

* sync to physics-shapes.md

* sync to push.md

* sync to test.md

* sync to working-offline.md

* update material.md

* update zerobrane.md

* all done

* Splitting .zip archives in live-update.md

* manual for collision events

* Updated sprite documentation to include info about multiple textures
  • Loading branch information
CocosGames authored Feb 2, 2024
1 parent 240d1db commit 48dadb6
Showing 1 changed file with 50 additions and 2 deletions.
52 changes: 50 additions & 2 deletions docs/zh/manuals/sprite.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ Sprite 组件使用 [图集](/manuals/atlas) 或者 [瓷砖图源](/manuals/tile
除了 *Id*, *Position**Rotation* 还有如下属性:

*Image*
: sprite所使用的图集或者瓷砖图源资源.
: 如果着色器有单个采样器, 该属性叫做 `Image`. 否则, 每个槽都以材质中的纹理采样器命名.
每个槽是指该 sprite 用于纹理采样器的图集或者瓷砖图源资源.

*DefaultAnimation*
: sprite的默认动画.
: sprite的默认动画. 动画信息取自第一个图集或者瓷砖图源.

*Material*
: sprite的渲染材质.
Expand Down Expand Up @@ -87,3 +88,50 @@ Sprite 可以覆盖当前分配材质中的顶点属性, 并将从组件传递
## 相关项目配置

*game.project* 文件里有些关于Sprite的 [设置项目](/manuals/project-settings#sprite).

## 多纹理 sprites

当一个 sprite 使用多个纹理时有些问题需要注意.

### 动画

动画数据 (fps, 帧名) 目前取自第一个纹理. 我们把它叫做 "驱动动画".

驱动动画的图片 id 用来查找其他纹理所用图片.
所以确保纹理间的帧 id 匹配是很重要的.

比如你的 `diffuse.atlas` 有一个 `run` 动画如下:

```
run:
/main/images/hero_run_color_1.png
/main/images/hero_run_color_2.png
...
```

那么帧 id 就是 `run/hero_run_color_1` 这难以在比如 `normal.atlas` 里找到:

```
run:
/main/images/hero_run_normal_1.png
/main/images/hero_run_normal_2.png
...
```

所以我们在 [图集](/manuals/material/) 里使用 `Rename patterns` 来重命名它们.
在相应图集里设置 `_color=``_normal=`, 然后你就能在两个图集里得到这样的帧名:

```
run/hero_run_1
run/hero_run_2
...
```

### UVs

UVs 取自第一个纹理. 因为只有一套顶点, 我们不能保证
如果第二个纹理有更多 UV 坐标或者有不同形状都能匹配得当.

所以要记住, 确保图片有足够相似的形状, 否则您可能会遇到纹理渗色.

每个纹理中图像的尺寸可以不同.

0 comments on commit 48dadb6

Please sign in to comment.