-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc95045
commit 55688f7
Showing
3 changed files
with
114 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
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 |
This file contains 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
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); |