update game assets structure
@ -79,6 +79,178 @@ Refers to images, audio, and other data that are specifically designed or adjust
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Asset Feature Manager
|
#### Custom Scaler
|
||||||
|
|
||||||
|
##### Overview
|
||||||
|
|
||||||
|
This script generates custom scaling ratios for assets in a Cocos Creator project, particularly handling different scaling needs for desktop and mobile platforms.
|
||||||
|
|
||||||
|
##### Configuration Steps
|
||||||
|
|
||||||
|
###### Create the Script
|
||||||
|
|
||||||
|
- Name the script: `custom-scale-data`
|
||||||
|
- Location: `assets/game-assets/scripts/custom-scaler/`
|
||||||
|
|
||||||
|
###### Configure the Script
|
||||||
|
|
||||||
|
- Refer to the following image for a general setup example:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
```js
|
||||||
|
// custom-scale-data.js
|
||||||
|
cc.CustomScaler.CustomScaleRatio["uuid0"] = 0.75;
|
||||||
|
cc.CustomScaler.CustomScaleRatio["uuid1"] = 0.7;
|
||||||
|
cc.CustomScaler.CustomScaleRatio["uuid2"] = 0.58;
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Asset Scaling Rules
|
||||||
|
|
||||||
|
Assets in the project should be scaled according to their type and location:
|
||||||
|
|
||||||
|
| Asset Type | Asset Path Contains | Condition | Scale Ratio |
|
||||||
|
|-----------------|---------------------|-------------------------------------------|-------------|
|
||||||
|
| Font files | `fnt-` | - | 1.0 |
|
||||||
|
| Desktop assets | `desktop` | Inside `custom-scale` folder | 1.0 |
|
||||||
|
| Desktop assets | `desktop` | Outside `custom-scale` folder | 0.75 |
|
||||||
|
| Mobile assets | `mobile` | Inside `custom-scale` folder | 0.7 |
|
||||||
|
| Mobile assets | `mobile` | Outside `custom-scale` folder | 0.58 |
|
||||||
|
|
||||||
|
**Folder structure:**
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
assets/
|
||||||
|
├── fnt-arial.png (.jpg) # remains at 1.0
|
||||||
|
├── desktop/
|
||||||
|
│ ├── sprite.png (.jpg) # scaled to 0.75
|
||||||
|
│ └── custom-scale/
|
||||||
|
│ └── sprite.png (.jpg) # remains at 1.0
|
||||||
|
└── mobile/
|
||||||
|
├── sprite.png (.jpg) # scaled to 0.58
|
||||||
|
└── custom-scale/
|
||||||
|
└── sprite.png (.jpg) # remains at 0.7
|
||||||
|
```
|
||||||
|
:::tip
|
||||||
|
Assets inside the `custom-scale` folder maintain their original quality, ensuring clear and sharp rendering.
|
||||||
|
:::
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
#### Prefabs
|
||||||
|
|
||||||
|
| Desktop Prefab | Mobile Prefab |
|
||||||
|
|:--------------:|:-------------:|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Asset Features Manager
|
||||||
|
|
||||||
#### Main Game Asset
|
#### Main Game Asset
|
||||||
#### Feature Game Asset
|
|
||||||
|
##### Overview
|
||||||
|
|
||||||
|
Main game assets are stored in the `main-game` folder, organized by platform and loading type:
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
assets/
|
||||||
|
└── game-assets/
|
||||||
|
├── Font/
|
||||||
|
| └──main-game
|
||||||
|
├── Sound/
|
||||||
|
| └──main-game
|
||||||
|
└── textures/
|
||||||
|
├── desktop/
|
||||||
|
│ ├── preload/ # Load at startup
|
||||||
|
| | └──main-game
|
||||||
|
│ └── postload/ # Load later
|
||||||
|
| └──main-game
|
||||||
|
|
|
||||||
|
└── mobile/
|
||||||
|
├── preload/ # Load at startup
|
||||||
|
| └──main-game
|
||||||
|
└── postload/ # Load later
|
||||||
|
└──main-game
|
||||||
|
```
|
||||||
|
|
||||||
|
- `desktop` and `mobile`: Separate folders for each platform.
|
||||||
|
- `preload`: Needed right away.
|
||||||
|
- `postload`: Can load after startup.
|
||||||
|
- Everything is organized under `main-game`.
|
||||||
|
|
||||||
|
|
||||||
|
##### Platform-Specific Structures
|
||||||
|
|
||||||
|
| Sound Example | Font Example |
|
||||||
|
|:-------------:|:-----------:|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
| Desktop Structure | Mobile Structure |
|
||||||
|
|:-----------------:|:---------------:|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
When a feature is activated, its assets are loaded directly, bypassing the main game asset folders.
|
||||||
|
:::
|
||||||
|
|
||||||
|
#### Feature Game Asset
|
||||||
|
|
||||||
|
##### Overview
|
||||||
|
|
||||||
|
Feature game assets (e.g., free-game, pickup, bonus, gamble) are stored in a folder named after the feature, and organized by platform (`desktop`, `mobile`) and loading type (`preload`, `postload`).
|
||||||
|
|
||||||
|
**Folder structure:**
|
||||||
|
```plaintext
|
||||||
|
assets/
|
||||||
|
└── game-assets/
|
||||||
|
├── Font/
|
||||||
|
| └──free-game
|
||||||
|
├── Sound/
|
||||||
|
| └──free-game
|
||||||
|
└── textures/
|
||||||
|
├── desktop/
|
||||||
|
│ ├── preload/ # Load at startup
|
||||||
|
| | └──free-game
|
||||||
|
│ └── postload/ # Load later
|
||||||
|
| └──free-game
|
||||||
|
|
|
||||||
|
└── mobile/
|
||||||
|
├── preload/ # Load at startup
|
||||||
|
| └──free-game
|
||||||
|
└── postload/ # Load later
|
||||||
|
└──free-game
|
||||||
|
```
|
||||||
|
##### Platform-Specific Structures
|
||||||
|
|
||||||
|
| Feature Game Example | Desktop Structure | Mobile Structure |
|
||||||
|
|:-----------:|:-----------------:|:---------------:|
|
||||||
|
|  |  |  |
|
||||||
|
|
||||||
|
#### Localizes Asset
|
||||||
|
|
||||||
|
`localizes/` là nơi lưu trữ assets của các ngôn ngữ khác nhau như : ZH, TH, ID..v.v
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
assets/
|
||||||
|
└── game-assets/
|
||||||
|
├── fonts/
|
||||||
|
│ ├── localizes/ # Localized font files
|
||||||
|
│ └── preloads/ # Fonts loaded at startup
|
||||||
|
└── textures/
|
||||||
|
├── desktop/
|
||||||
|
│ ├── localizes/ # Localized textures for desktop
|
||||||
|
│ ├── postloads/ # Desktop textures loaded after startup
|
||||||
|
│ └── preloads/ # Desktop textures loaded at startup
|
||||||
|
└── mobile/
|
||||||
|
├── localizes/ # Localized textures for mobile
|
||||||
|
├── postloads/ # Mobile textures loaded after startup
|
||||||
|
└── preloads/ # Mobile textures loaded at startup
|
||||||
|
```
|
||||||
|
sprite trong `preloads`, `postloads`: defaut là en
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
BIN
docs/04-game-asset-structure/img/assets-custom-scaler.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
docs/04-game-asset-structure/img/assets-structure-desktop.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
docs/04-game-asset-structure/img/assets-structure-mobile.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
docs/04-game-asset-structure/img/feature-assets-desktop.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
docs/04-game-asset-structure/img/feature-assets-mobile.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
docs/04-game-asset-structure/img/feature-assets.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
docs/04-game-asset-structure/img/font-main-game.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
docs/04-game-asset-structure/img/genernal-custom-scaler.png
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
docs/04-game-asset-structure/img/localizes-assets-zh.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
docs/04-game-asset-structure/img/localizes-assets.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
docs/04-game-asset-structure/img/prefabs-desktop.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
docs/04-game-asset-structure/img/prefabs-mobile.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
docs/04-game-asset-structure/img/sound-main-game.png
Normal file
After Width: | Height: | Size: 2.1 KiB |