2020-06-23 09:10:40 +08:00
|
|
|
class PostProcessor {
|
|
|
|
|
public enable: boolean;
|
|
|
|
|
public effect: egret.CustomFilter;
|
|
|
|
|
public scene: Scene;
|
|
|
|
|
public shape: egret.Shape;
|
|
|
|
|
|
|
|
|
|
constructor(effect: egret.CustomFilter = null){
|
2020-06-23 16:18:14 +08:00
|
|
|
this.enable = true;
|
2020-06-23 09:10:40 +08:00
|
|
|
this.effect = effect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public onAddedToScene(scene: Scene){
|
|
|
|
|
this.scene = scene;
|
|
|
|
|
this.shape = new egret.Shape();
|
2020-06-23 17:36:39 +08:00
|
|
|
this.shape.graphics.beginFill(0xFFFFFF, 1);
|
|
|
|
|
this.shape.graphics.drawRect(0, 0, SceneManager.stage.stageWidth, SceneManager.stage.stageHeight);
|
|
|
|
|
this.shape.graphics.endFill();
|
2020-06-23 09:10:40 +08:00
|
|
|
scene.addChild(this.shape);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-23 17:36:39 +08:00
|
|
|
public process(){
|
|
|
|
|
this.drawFullscreenQuad();
|
2020-06-23 09:10:40 +08:00
|
|
|
}
|
|
|
|
|
|
2020-06-23 16:18:14 +08:00
|
|
|
public onSceneBackBufferSizeChanged(newWidth: number, newHeight: number){}
|
|
|
|
|
|
2020-06-23 17:36:39 +08:00
|
|
|
protected drawFullscreenQuad(){
|
|
|
|
|
this.shape.filters = [this.effect];
|
2020-06-23 09:10:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public unload(){
|
|
|
|
|
if (this.effect){
|
|
|
|
|
this.effect = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.scene.removeChild(this.shape);
|
2020-06-23 16:18:14 +08:00
|
|
|
this.scene = null;
|
2020-06-23 09:10:40 +08:00
|
|
|
}
|
|
|
|
|
}
|