dungdq 7e836a98b9 Merge branch 'develop' into feature/add-setup-popup-panel
# Conflicts:
#	docs/02-setup-main-game/img/05-main-scene/add-reel-frame.png
2025-05-08 17:42:17 +07:00

22 KiB

sidebar_position
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

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 :::

Setup SpriteFrame Provider


**SpriteFrameProvider** allows global access to "sprite frames" from code.

![Sprite Frame Provider](./img/05-main-scene/sprite-frame-provider.png)

Setup Animation Provider


**Animation Provider** contains all **animations** of the game.

![Aniamtion Provider](./img/05-main-scene/animation-provider.png)

Setup Reel Slot


  1. Prepare the asset for symbols and reel frame.

    Add Symbol Texture Add Symbol Texture

  2. Add symbols to SpriteFrameProvider which allows those symbols to be accessed globally from the code.

    Sprite Frame Provider

  3. Add reel frame.

    Sprite Frame Provider Sprite Frame Provider

  4. Config reel slot using reel-scroller-helper.

    Reel Scroller Helper

    Properties Explaination Example
    Cell Item Script Name The name of the script will be attached to each cell item. cell-item-script-name
    Scroller Script Name the name of the script for handling the spinning logic. scroller
    Row Count x Reel Count the number of Slot Item each row and column in the reel slot panel. reel-row-column
    Cell Size the size of each cells. cell-size
    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
    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
  5. Generate panel using reel-scroller-helper.

    Generate Panel

:::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

  • Present Win Cell Panel:

    Present Win Cell Panel

  • Present Win Cell Panel:

    Present Win Border Panel

  • Tension Panel:

    Tension Panel

    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

Setup UI Panel

UI Panel Overview

The UI system supports both desktop and mobile layouts design.

🖥️ Desktop Layout

  • Full bottom bar with all controls visible
  • Horizontal layout maximizing screen width

Desktop UI Layout

📱 Mobile Layout

The mobile interface adapts to both landscape and portrait orientations:

Orientation Preview
Landscape Mobile Landscape
Portrait Mobile Portrait

UI Sideband

To Be Added:

  • Prepare the asset
  • Run helper / p4f menu or setup manually

UI Bottom Bar Desktop

Step 1: Setup Prefab Editor

Step Action image
1. Locate Prefab Search for ui-bottom-bar-panel prefab Locate Prefabs
2. Find Assets Navigate to core/editor directory Copy UI Folder
3. Clone Assets Copy / Paste to game assets location Asset Placement

Step 2: Configure Prefabs

Core Prefabs Structure

Navigate to the location where the prefabs: assets\core-assets\hyper-core\packages\ui\desktop-ui\prefabs\ Directory Structure

Rename Prefabs

Rename the copied prefabs by removing unnecessary prefixes:

Prefix to Remove Original Prefab Name Final Name
template-new- template-new-ui-bottom-bar-panel ui-bottom-bar-panel
template- template-button-auto-selection button-auto-selection
    assets\game-assets\prefabs

Prefab Naming Example

Customize button-auto-selection Label

Follow Design: Use the template-label-auto-selection to customize the appearance of the label inside the button-auto-selection prefab.

Component Description
Label Outline Add an outline to make the text stand out.
Label Shadow Add a shadow for better contrast and readability.
-------------------- -------------------------------------------------

Label Configuration Options

Customize ui-bottom-bar-panel Label

Use assets\game-assets\editor\bottom-ui\template-label-title to customize the ui-bottom-bar-panel:
:::info Follow the same configuration as Button Auto Selection Labels
Bottom bar labels include a localization component for multi-language support
:::

component-locale

The FormatText property controls text formatting behavior for label components:

Property Description Example
default Initial formatting state false
notify Formatting update callback Updates when value changes

Step 3: Setup UI In Main Scenes

Create new node and configuration in your main scene:
main scenes

Platform Node Spawner Settings
Setting Value Description
Desktop Toggle ✓ Enabled Show prefabs for desktop platform
Mobile Toggle ☐ Disabled Hide prefabs for mobile platform
Target Prefab ui-bottom-bar-panel References prefab

Step 4: Apply Textures

Texture Button Bar

Checklist assets completed for bottom UI and button UI text
🔗 Follow is by Complete Assets Structure Guide:
main scenes

Run the Helper Tool
  • Open the UI Desktop Helper
  • Select texture assignment options
    Helper Tool
Verify Results: all new asset already loaded to these prefab

button-auto-selection prefab
Auto Selection Result

ui-bottom-bar-panel prefab Bottom Bar Result

In game
Auto Selection Result
Bottom Bar Result


UI Panel Mobile

Step 1: Setup Prefab

Step Action Description Image Reference
1 Locate mobile-ui Prefab Search for the mobile-ui prefab Locate Prefabs
2 Clone Assets Copy the required assets Asset Placement
3 Paste Assets Paste into: assets/game-assets/prefabs/mobile -
4 Locate buy-feature Prefab Search for the buy-feature prefab Locate Prefabs
5 Paste Prefab Paste into: assets/game-assets/prefabs/mobile -

:::tip File Structure Maintain this directory structure for proper prefab references:

assets/
└── game-assets/
    └── prefabs/
        └── mobile/
            ├── Exp: mobile-ui.prefab
            └── Exp: buy-feature.prefab

:::

Step 2: Rename Prefabs

Rename the copied prefabs by removing unnecessary prefixes:

Prefix to Remove Final Name
template- Prefab Naming Example

Step 3: Setup Ui In Main Scenes

Create new node and configuration in your main scene:
main scenes

Platform Node Spawner Settings
Setting Value Description
Mobile Toggle ✓ Enabled Show prefabs for mobile platform
Desktop Toggle ☐ Disabled Hide prefabs for desktop platform
Target Prefab mobile-ui References prefab

Step 4: Apply Textures

Texture Mobile UI

Checklist assets completed for Mobile UI
🔗 Follow is by Complete Assets Structure Guide:
main scenes

Run the Helper Tool
  • Open the UI Mobile Helper
  • Select texture assignment options
    Helper Tool
Results

main ui button added textures
| Auto Selection Result |

Step 4: Setup Color For Menu Mobile UI

Follow Design:

Auto Selection Result Auto Selection Result
Overview

The helper-paint-color-ui-mobile.js component is a customizable color painter for various UI elements in a MOBILE UI. It allows designers and developers to easily apply theme-based colors across the game interface.

Auto Selection Result

Ordinal number Properties Explaination Example
0 paintColor Trigger to repaint UI components Auto Selection Result
1 Main Ui Normal Color Default color of UI elements Auto Selection ResultAuto Selection ResultAuto Selection ResultAuto Selection ResultAuto Selection ResultAuto Selection ResultAuto Selection ResultAuto Selection ResultAuto Selection ResultAuto Selection ResultAuto Selection ResultAuto Selection ResultAuto Selection ResultAuto Selection ResultAuto Selection ResultAuto Selection ResultAuto Selection Result
2 Main Ui Highlight Color Highlight color for selected UI elements Auto Selection ResultAuto Selection Result
3 Toggle State Off Color Color of toggle when off Auto Selection Result
4 Toggle State On Color Color of toggle when on Auto Selection Result
5 Background Info Page Color Info screen background Auto Selection Result
6 Background Menu Color Menu background color Auto Selection Result
7 Background Point Panel Color Background panel for point/balance UI Auto Selection Result
8 Background Bottom Bar Color Background bottom bar (show only mobile portrait) Auto Selection Result
9 Button Quit Color Quit button color Auto Selection Result
10 Button Cancel Color Cancel button color Auto Selection Result
11 Label Balance Normal Color Normal balance label color Auto Selection Result
12 Label Balance Spin Color During-spin label color Auto Selection Result
13 Button Plus Minus Auto Color Button plus/Minus autoplay Auto Selection Result
14 Label Start Auto Color Start autoplay label Auto Selection Result
15 Label Outline Notification Outline color + width config Auto Selection Result
16 Total Win Medium Win Color Color for medium win effects Auto Selection Result

Setup Background

Background overview:

Desktop Mobile
Background Landscape
Background Overview Landscape

Background Overview Landscape

Background Overview Landscape
Background Portrait
Background Overview Portrait

Background Overview Portrait

Background landscape use for Desktop and Mobile landscape.

Background portrait only use for Mobile portrait.

Prepare the assets

Assets Description
Static
Background Prepare Landscape Static background is necessary for the game
Animation
Background Prepare Portrait Animation background may or may not be present, depending on the game design

Background Landscape

We use sprite frame background for landscape from prepared assets.

![Background Setup Landscape](./img/05-main-scene/bg-setup-landscape.png)

Background Portrait

We use sprite frame background for mobile from prepared assets.

![Background Setup Portrait](./img/05-main-scene/bg-setup-portrait.png)

Background Animation

If the game have design animation for background, we will do this step.

  1. Using hepler to generate animation from prepared assets

    Background Setup Helper Anim Background Setup Helper Anim

  2. We have the result as below, and continue setup for spine-animation.

    • Is Loop: is because this animation will play through the game.
    • Static Sprite Frame: It will be displayed when the animation has not finished loading.

    Background Setup Animation Background Setup Animation

  3. Add animation background with component below:

    Animation background landscape

    • Create Empty Node with name anim-background-main-game.
    • Add animation-play-on-anable with animation name in Animation Provider.
    • Add background-scaler resize with screen resolution.

    Background Setup Anim Landscape

    Animation background portrait

    • Create Empty Node with name mobile-background-anim-portrait.
    • Add mobile-portrait-background-ui-controller to display only on Mobile.
    • Add orientation-ui-controller to display on Portrait with the options below.

    Background Setup Anim Portrait

    • Create Empty Node with name anim-background-main-game.
    • Add animation-play-on-anable with animation name in Animation Provider.
    • Add portrait-anim-background-scaler resize with screen resolution.

    Background Setup Anim Portrait

Setup Popup Panel

Overview

A popup is a temporary UI element that provides additional information or options to the user.

Popup overview exit Popup overview disconnect Popup overview disconnect

Popup in the Game

The popup panel is already integrated into the main scenes template-main-game.

Popup In Game

Node Type Location Description Screenshot
Definition Node Before configuring the popup prefab Popup Definition
Positioning Node After adjusting the prefab's position in scene Popup Position

Detail configuring:

Multiple Popup Panel:

Popup Position

To use the Multiple Popup layout, reference target hyper-multiple-popup.prefab in core: :::info Path : assets/core-assets/hyper-core/packages/popup-panel/prefabs/hyper-multiple-popup.prefab
:::

Manual Popup Panel:
  • This popup is self-configured using shared textures and layout structure.
  • The color theme and style may vary depending on the game design.

⚠️ Note: The Exit Game Popup only appears in Desktop.

Exit Game Popup In Game

Texture Path & Asset Info:

Exit popup textures have been successfully packed.
🔗 Refer to the full asset structure guide: Complete Assets Structure Guide

Texture Path::
assets\game-assets\textures\desktop\preloads\main-game\exit

Preview Result:
Popup overview exit