Created
February 10, 2021 12:06
-
-
Save photonstorm/b3f9ed1a5457f8d5f0ff7d3387dc71fd to your computer and use it in GitHub Desktop.
Phaser FX TypeScript Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Phaser from 'phaser'; | |
import { DoomWipePostFX } from './DoomWipePostFX'; | |
class Example extends Phaser.Scene | |
{ | |
constructor () | |
{ | |
super('Example'); | |
} | |
preload () | |
{ | |
this.load.image('pic1', 'assets/doom1.jpg'); | |
this.load.image('pic2', 'assets/doom2.jpg'); | |
} | |
create () | |
{ | |
const renderer = this.renderer as Phaser.Renderer.WebGL.WebGLRenderer; | |
renderer.pipelines.addPostPipeline('DoomWipePostFX', DoomWipePostFX); | |
const pic1 = this.add.image(400, 300, 'pic1').setPostPipeline(DoomWipePostFX); | |
const pipeline = pic1.getPostPipeline(DoomWipePostFX) as DoomWipePostFX; | |
pipeline.setTexture('pic2', 0); | |
this.tweens.add({ | |
targets: pipeline, | |
progress: 1, | |
hold: 2000, | |
delay: 2000, | |
repeatDelay: 2000, | |
repeat: -1, | |
duration: 3000 | |
}); | |
} | |
} | |
const config = { | |
type: Phaser.WEBGL, | |
width: 800, | |
height: 600, | |
backgroundColor: '#000000', | |
parent: 'phaser-example', | |
scene: Example | |
}; | |
let game = new Phaser.Game(config); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment