monsterplex/src/scenes/IntroScene.js

47 lines
1.3 KiB
JavaScript

import Phaser from 'phaser';
import { GAME_WIDTH, GAME_HEIGHT, WORLD_SCALE } from '../config.js';
import { playMenuMusic } from '../util/music.js';
export default class IntroScene extends Phaser.Scene {
constructor() {
super('Intro');
}
create() {
this.cameras.main.setBackgroundColor('#8fc7e8');
playMenuMusic(this);
this.add.text(GAME_WIDTH / 2, GAME_HEIGHT / 2 - 60 * WORLD_SCALE, 'MONSTERPLEX', {
fontFamily: 'monospace',
fontSize: `${52 * WORLD_SCALE}px`,
color: '#1a1f29',
fontStyle: 'bold',
}).setOrigin(0.5);
this.add.text(GAME_WIDTH / 2, GAME_HEIGHT / 2, 'a school bus survival ride', {
fontFamily: 'monospace',
fontSize: `${18 * WORLD_SCALE}px`,
color: '#2255aa',
}).setOrigin(0.5);
const prompt = this.add.text(GAME_WIDTH / 2, GAME_HEIGHT - 90 * WORLD_SCALE, 'Press any key or tap to continue', {
fontFamily: 'monospace',
fontSize: `${16 * WORLD_SCALE}px`,
color: '#1a1f29',
}).setOrigin(0.5);
this.tweens.add({
targets: prompt,
alpha: { from: 1, to: 0.2 },
duration: 700,
yoyo: true,
repeat: -1,
});
this._advance = () => this.scene.start('MainMenu');
this.input.keyboard.once('keydown', this._advance);
this.input.once('pointerdown', this._advance);
this.time.delayedCall(6000, this._advance);
}
}