赞 | 7 |
VIP | 7 |
好人卡 | 58 |
积分 | 1 |
经验 | 111901 |
最后登录 | 2024-11-30 |
在线时间 | 386 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 70
- 在线时间
- 386 小时
- 注册时间
- 2007-7-27
- 帖子
- 4106
|
首先窗口是WindowLayer负责渲染的
然后WindowLayer在画窗口的时候,会首先该清除矩形区域,造成只有一层的假象
修改很简单
将下面插入一个js文件,作为插件开启- WindowLayer.prototype._canvasClearWindowRect = function(renderSession, window) {
- };
- WindowLayer.prototype._webglMaskWindow = function(renderSession, window) {
- };
- WindowLayer.prototype._renderCanvas = function(renderSession) {
- if (!this.visible) {
- return;
- }
- if (!this._tempCanvas) {
- this._tempCanvas = document.createElement('canvas');
- }
- this._tempCanvas.width = Graphics.width;
- this._tempCanvas.height = Graphics.height;
- var realCanvasContext = renderSession.context;
- var context = this._tempCanvas.getContext('2d');
- context.save();
- context.clearRect(0, 0, Graphics.width, Graphics.height);
- context.beginPath();
- context.rect(this.x, this.y, this.width, this.height);
- context.closePath();
- context.clip();
- renderSession.context = context;
- for (var i = 0; i < this.children.length; i++) {
- var child = this.children[i];
- if (child._isWindow && child.visible && child.openness > 0) {
- this._canvasClearWindowRect(renderSession, child);
- context.save();
- child._renderCanvas(renderSession);
- context.restore();
- }
- }
- context.restore();
- renderSession.context = realCanvasContext;
- renderSession.context.setTransform(1, 0, 0, 1, 0, 0);
- renderSession.context.globalCompositeOperation = 'source-over';
- renderSession.context.globalAlpha = 1;
- renderSession.context.drawImage(this._tempCanvas, 0, 0);
- for (var j = 0; j < this.children.length; j++) {
- if (!this.children[j]._isWindow) {
- this.children[j]._renderCanvas(renderSession);
- }
- }
- };
- WindowLayer.prototype._renderWebGL = function(renderSession) {
- if (!this.visible) {
- return;
- }
- var gl = renderSession.gl;
- if (!this._vertexBuffer) {
- this._vertexBuffer = gl.createBuffer();
- }
- this._dummySprite._renderWebGL(renderSession);
- renderSession.spriteBatch.stop();
- gl.enable(gl.STENCIL_TEST);
- gl.clear(gl.STENCIL_BUFFER_BIT);
- this._webglMaskOutside(renderSession);
- renderSession.spriteBatch.start();
- for (var i = 0; i < this.children.length; i++) {
- var child = this.children[i];
- if (child._isWindow && child.visible && child.openness > 0) {
- gl.stencilFunc(gl.EQUAL, 0, 0xFF);
- child._renderWebGL(renderSession);
- renderSession.spriteBatch.stop();
- this._webglMaskWindow(renderSession, child);
- renderSession.spriteBatch.start();
- }
- }
- gl.disable(gl.STENCIL_TEST);
- for (var j = 0; j < this.children.length; j++) {
- if (!this.children[j]._isWindow) {
- this.children[j]._renderWebGL(renderSession);
- }
- }
- };
复制代码 |
评分
-
查看全部评分
|