Add music and voice assets
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import Phaser from 'phaser';
|
||||
import { soundDirector } from '../audio/SoundDirector';
|
||||
import { firstBattleMap, firstBattleUnits, type TerrainType, type UnitData } from '../data/scenario';
|
||||
import { palette } from '../ui/palette';
|
||||
|
||||
@@ -24,6 +25,8 @@ export class BattleScene extends Phaser.Scene {
|
||||
|
||||
create() {
|
||||
const { width, height } = this.scale;
|
||||
soundDirector.stopVoice();
|
||||
soundDirector.playMusic('battle-prep');
|
||||
this.add.rectangle(0, 0, width, height, 0x0f1418).setOrigin(0);
|
||||
this.drawMap();
|
||||
this.drawUnits();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import Phaser from 'phaser';
|
||||
import { soundDirector } from '../audio/SoundDirector';
|
||||
import { prologuePages, type PortraitKey, type StoryPage } from '../data/scenario';
|
||||
import { palette } from '../ui/palette';
|
||||
|
||||
@@ -114,6 +115,8 @@ export class StoryScene extends Phaser.Scene {
|
||||
}
|
||||
|
||||
private applyPage(page: StoryPage) {
|
||||
soundDirector.playMusic(page.bgm);
|
||||
soundDirector.playVoice(page.voice, page.voiceRole ?? page.portrait ?? 'narrator');
|
||||
this.applyBackground(page.background);
|
||||
this.chapterText?.setText(page.chapter);
|
||||
|
||||
|
||||
@@ -17,8 +17,15 @@ export class TitleScene extends Phaser.Scene {
|
||||
this.drawTitleMark(width, height);
|
||||
this.drawMenu(width, height);
|
||||
|
||||
this.input.once('pointerdown', () => soundDirector.start());
|
||||
this.input.keyboard?.once('keydown', () => soundDirector.start());
|
||||
soundDirector.playMusic('title-theme');
|
||||
const unlockAudio = () => {
|
||||
soundDirector.start();
|
||||
soundDirector.resume();
|
||||
soundDirector.playMusic('title-theme');
|
||||
};
|
||||
|
||||
this.input.once('pointerdown', unlockAudio);
|
||||
this.input.keyboard?.once('keydown', unlockAudio);
|
||||
this.input.keyboard?.once('keydown-ENTER', () => this.startGame());
|
||||
}
|
||||
|
||||
@@ -275,6 +282,8 @@ export class TitleScene extends Phaser.Scene {
|
||||
}
|
||||
|
||||
private startGame() {
|
||||
soundDirector.start();
|
||||
soundDirector.resume();
|
||||
soundDirector.playSelect();
|
||||
this.scene.start('StoryScene');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user