Skip to content

Instantly share code, notes, and snippets.

@photonstorm
Created February 10, 2021 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save photonstorm/b3f9ed1a5457f8d5f0ff7d3387dc71fd to your computer and use it in GitHub Desktop.
Save photonstorm/b3f9ed1a5457f8d5f0ff7d3387dc71fd to your computer and use it in GitHub Desktop.
Phaser FX TypeScript Example
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