Level-Up Animation System

Learn how the XP progress bar animates and displays level-ups during battle results.

Overview

The level-up system uses two main components:

  • XPProgresBar.tsx - Animated XP bar with level-up detection

  • PartyMemberReward.tsx - Battle results card showing XP gain and level-ups

How It Works

Animation Flow

1. Start with pre-battle XP

2. Animate toward post-battle XP

3. Detect when XP crosses level threshold

4. Fill bar to 100% → Show level-up → Reset bar for next level

5. Continue animating toward final XP

6. Show "LEVEL UP!" notification with final level

XPProgresBar Component

File: menus/src/components/XPProgresBar.tsx

Key Features

  • Animates from startExp to targetExp over 1 second

  • Detects level-ups during animation

  • Updates level display in real-time

  • Supports skip functionality

  • Exposes level-up events via ref handle

Props

Usage

Level-Up Detection Logic

The component pre-calculates all level-up thresholds:

During animation, check if thresholds are crossed:

Skip Functionality

The component exposes a ref handle for skipping:

PartyMemberReward Component

File: menus/src/components/PartyMemberReward.tsx

Wraps XPProgresBar and shows level-up notification.

Structure

Capturing Level-Ups

BattleResults Integration

File: menus/src/views/battle/BattleResults.tsx

Shows all party members' XP gains:

Customization Examples

Custom Level-Up Animation

Custom XP Bar Styling

Sound Effects

Multiple Level-Ups

If actor gains multiple levels:

Common Issues

Level doesn't update during animation

Cause: Not updating displayLevel state when threshold crossed

Fix: Ensure setDisplayLevel() called in animator loop

Bar shows wrong progress after level-up

Cause: Not updating displayNextXp when leveling up

Fix:

Skip jumps to wrong level

Cause: Not setting final level state in skip function

Fix:

Performance Tips

  • Use refs for animation state to avoid re-renders

  • Only update display state when actually needed

  • Cancel animation frames on unmount

  • Throttle display updates if animating many actors

See Also

Last updated