168 lines
5.6 KiB
Markdown

---
sidebar_position: 5
---
# Main Scene
This is where all the magic happen.
---
Main scene is the most complicated scene with hundreds of object, script and config.
![Main Scene Wireframe](./img/05-main-scene/main-scene-wireframe.png)
Yet it is suprisingly simple to use.
By following step by step setup, you'll have a working main scene in no time.
:::info
In fact, if all of the other scenes are setup properly, you can even run test the game without any setup on main scene.
Try to run the project, you'll the result as below. It doesn't look like much but it is actually a game running without visual assets.
![Run Test](./img/05-main-scene/run-test.png)
:::
## Setup Reel Slot
---
1. Prepare the asset for symbols.
![Add Symbol Texture](./img/05-main-scene/add-symbol-texture.png)
2. Add symbols to **SpriteFrameProvider** which allows those symbols to be accessed globally from the code.
![Sprite Frame Provider](./img/05-main-scene/sprite-frame-provider.png)
3. Config reel slot using `reel-scroller-helper`.
![Reel Scroller Helper](./img/05-main-scene/reel-scroller-helper.png)
| Properties | Explaination | Example |
|------------|--------------|---------|
|**Cell Item Script Name**|The name of the script will be attached to each cell item.|![cell-item-script-name](./img/05-main-scene/hyper-cell-item.png)|
| **Scroller Script Name** | the name of the script for handling the spinning logic.|![scroller](./img/05-main-scene/scroller.png)|
|**Row Count x Reel Count**| the number of Slot Item each row and column in the reel slot panel.|![reel-row-column](./img/05-main-scene/reel-row-column.png)|
|**Cell Size**| the size of each cells.|![cell-size](./img/05-main-scene/cell-size.png)|
|**Cell Spacing**| the distance between each cells horizontally and vertically.||
|**Cell Dim Color**| set the dark color for the non-win cells when showing winning animation for each line.|![dim-cell-color](./img/05-main-scene/dim-cell-color.png)|
|**Top Count and Bot Count**| for spinning logic to work, a certain number of cell will be added to the top and bottom of the reel.|![cell-top-bottom](./img/05-main-scene/cell-top-bottom.png)|
4. Generate panel using `reel-scroller-helper`.
![Generate Panel](./img/05-main-scene/generate-panel.png)
:::tip
There is a popup panel covering the entire game scene. You should turn off this panel to see the other component clearly.
:::
## Setup Spinning Panel
Reel slot panel is just one part one the spinning panel.
There are other panels that need to be setup: **landing-panel**, **tension-panel**, **present-win-cell-panel** and **present-win-border-panel**.
The setup is very straightforward by using the `Generate Panel` command in each panel's helper class.
- Landing Panel:
![Landing Panel](./img/05-main-scene/landing-panel.png)
- Present Win Cell Panel:
![Present Win Cell Panel](./img/05-main-scene/present-win-cell-panel.png)
- Present Win Cell Panel:
![Present Win Border Panel](./img/05-main-scene/present-win-border-panel.png)
- Tension Panel:
![Tension Panel](./img/05-main-scene/tension-panel.png)
If the tension use a custom size frame, we can change the option **sizeMode** to **Custom** and set the static frame and size.
![Tension Size Custom](./img/05-main-scene/tension-panel-custom.png)
## Setup UI Panel
> To be Added:
> - Different UI Layout on Desktop and Mobile
> - Which helper/p4f menu can be used
## Setup Background
### Background Desktop
1. Prepare for **Background Animation**.
- Assets
![Background Landscape](./img/05-main-scene/background-landscape-1.png)
![Background Landscape](./img/05-main-scene/background-landscape-2.png)
- Node Tree and Properties
Animation Provider: We add anim-landscape in desktop assets , it is used for desktop and mobile landscape.
![Background Landscape](./img/05-main-scene/background-landscape-4.png)
Background Container
![Background Landscape](./img/05-main-scene/background-landscape-3.png)
2. Set up **Background** for **Main Game**.
- Static
![Background Landscape](./img/05-main-scene/background-landscape-5.png)
If we have animation background, we can remove **Sprite Component** to decrease Drawcall, because we already have static sprite frame on **Spine Animation Component**.
- Animation
![Background Landscape](./img/05-main-scene/background-landscape-6.png)
### Background Mobile
1. Prepare for **Background Animation**.
- Assets
![Background Landscape](./img/05-main-scene/background-landscape-7.png)
![Background Landscape](./img/05-main-scene/background-landscape-8.png)
- Node Tree and Properties
Animation Provider: We add anim-portrait in mobile assets, anim-landscape we still use desktop assets.
![Background Landscape](./img/05-main-scene/background-landscape-9.png)
Background Container
![Background Landscape](./img/05-main-scene/background-landscape-10.png)
2. Set up **Background** for **Main Game**.
- Static
![Background Landscape](./img/05-main-scene/background-landscape-11.png)
If we have animation background, we can remove **Sprite Component** to decrease Drawcall, because we already have static sprite frame on **Spine Animation Component**.
- Animation
![Background Landscape](./img/05-main-scene/background-landscape-12.png)
![Background Landscape](./img/05-main-scene/background-landscape-13.png)
![Background Landscape](./img/05-main-scene/background-landscape-14.png)
## Setup Animation Provider
> To Be Added:
> - How to run helper / p4f menu
> - How to setup static frame / fps
## Setup Popup Panel
> To Be Added:
> - Prepare the asset
> - Run helper / p4f menu or setup manually