Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
rexrainbow committed Oct 10, 2024
1 parent cc95045 commit 55688f7
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/docs/shader-dissolve.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Dissolve transition post processing filter. ([Reference](https://github.com/ykob

### Apply effect

- Apply effect to game object. A game object only can add 1 gray-scale effect.
- Apply effect to game object. A game object only can add 1 dissolve effect.
```javascript
var pipelineInstance = scene.plugins.get('rexDissolvePipeline').add(gameObject, {
// toTexture: textureKey,
Expand Down Expand Up @@ -125,7 +125,7 @@ Dissolve transition post processing filter. ([Reference](https://github.com/ykob
- `undefined` : A random value.
- `fromEdgeStart`, `fromEdgeWidth` : Dissolve edge start, edge width of from-texture (texture of game object, or render result of camera).
- `toEdgeStart`, `toEdgeWidth` : Reveal edge start, edge width of to-texture.
- Apply effect to camera. A camera only can add 1 gray-scale effect.
- Apply effect to camera. A camera only can add 1 dissolve effect.
```javascript
var pipelineInstance = scene.plugins.get('rexDissolvePipeline').add(camera, config);
```
Expand Down
5 changes: 5 additions & 0 deletions examples/shader-dissolve/camera-postfx.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
set main=./examples/shader-dissolve/camera-postfx.js
cd ..
cd ..
npm run watch
107 changes: 107 additions & 0 deletions examples/shader-dissolve/camera-postfx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import phaser from 'phaser/src/phaser.js';
import DissolvePipelinePlugin from '../../plugins/dissolvepipeline-plugin.js';

var DissolveMainCamera = function (scene, duration) {
var postFxPlugin = scene.plugins.get('rexDissolvePipelinePlugin');
var mainCamera = scene.cameras.main;

var postFxPipeline = postFxPlugin.add(mainCamera, {
});

scene.tweens.add({
targets: postFxPipeline,
progress: 1,
ease: 'Quad', // 'Cubic', 'Elastic', 'Bounce', 'Back'
duration: duration,
repeat: 0, // -1: infinity
yoyo: false
})
.on('complete', function () {
postFxPlugin.remove(mainCamera);
})
}

class SceneA extends Phaser.Scene {
constructor() {
super({
key: 'SceneA'
})
}

preload() {
this.load.image('classroom', 'assets/images/backgrounds/classroom.png');
}

create() {
console.log('Create SceneA');
this.add.image(400, 300, 'classroom');

this.input.on('pointerdown', function () {
this.scene.transition({
target: 'SceneB',
duration: 2000,
moveBelow: true,

onStart(fromScene, toScene, duration) {
DissolveMainCamera(fromScene, duration);
}
});
}, this)
}

update() {
}
}

class SceneB extends Phaser.Scene {
constructor() {
super({
key: 'SceneB'
})
}

preload() {
this.load.image('road', 'assets/images/backgrounds/road.png');
}

create() {
console.log('Create SceneB');
this.add.image(400, 300, 'road');

this.input.on('pointerdown', function () {
this.scene.transition({
target: 'SceneA',
duration: 2000,
moveBelow: true,

onStart(fromScene, toScene, duration) {
DissolveMainCamera(fromScene, duration);
}
});
}, this)
}

update() {
}
}

var config = {
type: Phaser.AUTO,
parent: 'phaser-example',
width: 800,
height: 600,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
},
scene: [SceneA, SceneB],
plugins: {
global: [{
key: 'rexDissolvePipelinePlugin',
plugin: DissolvePipelinePlugin,
start: true
}]
}
};

var game = new Phaser.Game(config);

0 comments on commit 55688f7

Please sign in to comment.