Scene plugin for Phaser3.
Play any video and enable to skip with configurable key input.
- Copy the
NhbIntroPlugin.js
anywhere you like. I like to put those in aplugins
folder in my root directory. - Register scene plugin in your game config:
import NhbIntroPlugin from '@/plugins/NhbIntroPlugin'
const gameConfig = {
plugins: {
scene: {
{
key: 'NHBIntroPlugin',
plugin: NhbIntroPlugin,
mapping: 'introManager', // Can be anything you like
},
},
},
}
- Load your video in a scene and use the plugin:
import Phaser from 'phaser'
class MyScene extends Phaser.Scene {
preload () {
this.load.video('nhb_intro', 'assets/videos/nhb_intro.mp4', 'loadeddata', false, false)
}
async create () {
// Use default settings (Skip via ENTER or SPACE)
await this.introManager.playIntro('nhb_intro')
// Or overwrite keys used to skip the video. For example: S
await this.introManager.playIntro('nhb_intro', { skipKeys: ['S'] })
// Start any scene after intro video finished
this.scene.start('myStartScene')
}
}