新增场景截图 requestScreenshot

This commit is contained in:
yhh
2020-08-12 19:57:06 +08:00
parent c89ed25d8a
commit 4012a9f6d1
7 changed files with 49 additions and 9 deletions
+2
View File
@@ -348,6 +348,7 @@ declare module es {
readonly entities: EntityList; readonly entities: EntityList;
readonly renderableComponents: RenderableComponentList; readonly renderableComponents: RenderableComponentList;
readonly entityProcessors: EntityProcessorList; readonly entityProcessors: EntityProcessorList;
_screenshotRequestCallback: Function;
readonly _sceneComponents: SceneComponent[]; readonly _sceneComponents: SceneComponent[];
_renderers: Renderer[]; _renderers: Renderer[];
readonly _postProcessors: PostProcessor[]; readonly _postProcessors: PostProcessor[];
@@ -364,6 +365,7 @@ declare module es {
update(): void; update(): void;
render(): void; render(): void;
postRender(): void; postRender(): void;
requestScreenshot(callback: Function): void;
addSceneComponent<T extends SceneComponent>(component: T): T; addSceneComponent<T extends SceneComponent>(component: T): T;
getSceneComponent<T extends SceneComponent>(type: any): T; getSceneComponent<T extends SceneComponent>(type: any): T;
getOrCreateSceneComponent<T extends SceneComponent>(type: any): T; getOrCreateSceneComponent<T extends SceneComponent>(type: any): T;
+9
View File
@@ -1719,6 +1719,15 @@ var es;
} }
} }
} }
if (this._screenshotRequestCallback) {
var tex = new egret.RenderTexture();
tex.drawToTexture(this, new es.Rectangle(0, 0, this.stage.stageWidth, this.stage.stageHeight));
this._screenshotRequestCallback(tex);
this._screenshotRequestCallback = null;
}
};
Scene.prototype.requestScreenshot = function (callback) {
this._screenshotRequestCallback = callback;
}; };
Scene.prototype.addSceneComponent = function (component) { Scene.prototype.addSceneComponent = function (component) {
component.scene = this; component.scene = this;
File diff suppressed because one or more lines are too long
+2
View File
@@ -348,6 +348,7 @@ declare module es {
readonly entities: EntityList; readonly entities: EntityList;
readonly renderableComponents: RenderableComponentList; readonly renderableComponents: RenderableComponentList;
readonly entityProcessors: EntityProcessorList; readonly entityProcessors: EntityProcessorList;
_screenshotRequestCallback: Function;
readonly _sceneComponents: SceneComponent[]; readonly _sceneComponents: SceneComponent[];
_renderers: Renderer[]; _renderers: Renderer[];
readonly _postProcessors: PostProcessor[]; readonly _postProcessors: PostProcessor[];
@@ -364,6 +365,7 @@ declare module es {
update(): void; update(): void;
render(): void; render(): void;
postRender(): void; postRender(): void;
requestScreenshot(callback: Function): void;
addSceneComponent<T extends SceneComponent>(component: T): T; addSceneComponent<T extends SceneComponent>(component: T): T;
getSceneComponent<T extends SceneComponent>(type: any): T; getSceneComponent<T extends SceneComponent>(type: any): T;
getOrCreateSceneComponent<T extends SceneComponent>(type: any): T; getOrCreateSceneComponent<T extends SceneComponent>(type: any): T;
+9
View File
@@ -1719,6 +1719,15 @@ var es;
} }
} }
} }
if (this._screenshotRequestCallback) {
var tex = new egret.RenderTexture();
tex.drawToTexture(this, new es.Rectangle(0, 0, this.stage.stageWidth, this.stage.stageHeight));
this._screenshotRequestCallback(tex);
this._screenshotRequestCallback = null;
}
};
Scene.prototype.requestScreenshot = function (callback) {
this._screenshotRequestCallback = callback;
}; };
Scene.prototype.addSceneComponent = function (component) { Scene.prototype.addSceneComponent = function (component) {
component.scene = this; component.scene = this;
+1 -1
View File
File diff suppressed because one or more lines are too long
+18
View File
@@ -27,6 +27,8 @@ module es {
*/ */
public readonly entityProcessors: EntityProcessorList; public readonly entityProcessors: EntityProcessorList;
public _screenshotRequestCallback: Function;
public readonly _sceneComponents: SceneComponent[] = []; public readonly _sceneComponents: SceneComponent[] = [];
public _renderers: Renderer[] = []; public _renderers: Renderer[] = [];
public readonly _postProcessors: PostProcessor[] = []; public readonly _postProcessors: PostProcessor[] = [];
@@ -184,6 +186,22 @@ module es {
} }
} }
} }
// 如果我们有一个屏幕截图请求处理它之前,最后渲染到backbuffer
if (this._screenshotRequestCallback){
let tex = new egret.RenderTexture();
tex.drawToTexture(this, new Rectangle(0, 0, this.stage.stageWidth, this.stage.stageHeight));
this._screenshotRequestCallback(tex);
this._screenshotRequestCallback = null;
}
}
/**
*
* @param callback
*/
public requestScreenshot(callback: Function){
this._screenshotRequestCallback = callback;
} }
/** /**