Skip to content

Commit f15a896

Browse files
committed
fix bug and add RenderNode
1 parent 8097971 commit f15a896

File tree

12 files changed

+317
-74
lines changed

12 files changed

+317
-74
lines changed

build/egret/egret.d.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9653,6 +9653,14 @@ declare module egret.sys {
96539653
* 组渲染节点
96549654
*/
96559655
GroupNode = 4,
9656+
/**
9657+
* 设置矩阵节点
9658+
*/
9659+
SetTransformNode = 5,
9660+
/**
9661+
* 设置透明度节点
9662+
*/
9663+
SetAlphaNode = 6,
96569664
}
96579665
/**
96589666
* @private
@@ -9782,11 +9790,38 @@ declare module egret.sys {
97829790
addNode(node: RenderNode): void;
97839791
/**
97849792
* 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。
9793+
* 这里只是想清空绘制命令,因此不调用super
97859794
*/
97869795
cleanBeforeRender(): void;
97879796
$getRenderCount(): number;
97889797
}
97899798
}
9799+
declare module egret.sys {
9800+
/**
9801+
* @private
9802+
* 位图渲染节点
9803+
*/
9804+
class SetAlphaNode extends RenderNode {
9805+
constructor();
9806+
/**
9807+
* 绘制一次位图
9808+
*/
9809+
setAlpha(alpha: number): void;
9810+
}
9811+
}
9812+
declare module egret.sys {
9813+
/**
9814+
* @private
9815+
* 位图渲染节点
9816+
*/
9817+
class SetTransformNode extends RenderNode {
9818+
constructor();
9819+
/**
9820+
* 绘制一次位图
9821+
*/
9822+
setTransform(a: number, b: number, c: number, d: number, tx: number, ty: number): void;
9823+
}
9824+
}
97909825
declare module egret.sys {
97919826
/**
97929827
* @private
@@ -10107,6 +10142,10 @@ declare module egret {
1010710142
* @param forHitTest 绘制结果是用于碰撞检测。若为true,当渲染GraphicsNode时,会忽略透明度样式设置,全都绘制为不透明的。
1010810143
*/
1010910144
drawNodeToBuffer(node: sys.RenderNode, buffer: sys.RenderBuffer, matrix: Matrix, forHitTest?: boolean): void;
10145+
/**
10146+
* @private
10147+
*/
10148+
private renderNode(node, context, forHitTest?);
1011010149
/**
1011110150
* @private
1011210151
*/

build/egret/egret.js

Lines changed: 133 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,7 +2406,6 @@ var egret;
24062406
else {
24072407
var buffer = egret.sys.hitTestBuffer;
24082408
buffer.resize(3, 3);
2409-
var node = this.$getRenderNode();
24102409
var matrix = egret.Matrix.create();
24112410
matrix.identity();
24122411
matrix.translate(1 - localX, 1 - localY);
@@ -14637,6 +14636,7 @@ var egret;
1463714636
};
1463814637
/**
1463914638
* 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。
14639+
* 这里只是想清空绘制命令,因此不调用super
1464014640
*/
1464114641
p.cleanBeforeRender = function () {
1464214642
var data = this.drawData;
@@ -14686,6 +14686,124 @@ var egret;
1468614686
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1468714687
//
1468814688
//////////////////////////////////////////////////////////////////////////////////////
14689+
var egret;
14690+
(function (egret) {
14691+
var sys;
14692+
(function (sys) {
14693+
/**
14694+
* @private
14695+
* 位图渲染节点
14696+
*/
14697+
var SetAlphaNode = (function (_super) {
14698+
__extends(SetAlphaNode, _super);
14699+
function SetAlphaNode() {
14700+
_super.call(this);
14701+
this.type = 6 /* SetAlphaNode */;
14702+
}
14703+
var d = __define,c=SetAlphaNode,p=c.prototype;
14704+
/**
14705+
* 绘制一次位图
14706+
*/
14707+
p.setAlpha = function (alpha) {
14708+
if (this.drawData.length != 0) {
14709+
this.drawData.length = 0;
14710+
}
14711+
this.drawData.push(alpha);
14712+
this.renderCount++;
14713+
};
14714+
return SetAlphaNode;
14715+
})(sys.RenderNode);
14716+
sys.SetAlphaNode = SetAlphaNode;
14717+
egret.registerClass(SetAlphaNode,'egret.sys.SetAlphaNode');
14718+
})(sys = egret.sys || (egret.sys = {}));
14719+
})(egret || (egret = {}));
14720+
//////////////////////////////////////////////////////////////////////////////////////
14721+
//
14722+
// Copyright (c) 2014-2015, Egret Technology Inc.
14723+
// All rights reserved.
14724+
// Redistribution and use in source and binary forms, with or without
14725+
// modification, are permitted provided that the following conditions are met:
14726+
//
14727+
// * Redistributions of source code must retain the above copyright
14728+
// notice, this list of conditions and the following disclaimer.
14729+
// * Redistributions in binary form must reproduce the above copyright
14730+
// notice, this list of conditions and the following disclaimer in the
14731+
// documentation and/or other materials provided with the distribution.
14732+
// * Neither the name of the Egret nor the
14733+
// names of its contributors may be used to endorse or promote products
14734+
// derived from this software without specific prior written permission.
14735+
//
14736+
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
14737+
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
14738+
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
14739+
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
14740+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
14741+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
14742+
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
14743+
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
14744+
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
14745+
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14746+
//
14747+
//////////////////////////////////////////////////////////////////////////////////////
14748+
var egret;
14749+
(function (egret) {
14750+
var sys;
14751+
(function (sys) {
14752+
/**
14753+
* @private
14754+
* 位图渲染节点
14755+
*/
14756+
var SetTransformNode = (function (_super) {
14757+
__extends(SetTransformNode, _super);
14758+
function SetTransformNode() {
14759+
_super.call(this);
14760+
this.type = 5 /* SetTransformNode */;
14761+
}
14762+
var d = __define,c=SetTransformNode,p=c.prototype;
14763+
/**
14764+
* 绘制一次位图
14765+
*/
14766+
p.setTransform = function (a, b, c, d, tx, ty) {
14767+
if (this.drawData.length != 0) {
14768+
this.drawData.length = 0;
14769+
}
14770+
this.drawData.push(a, b, c, d, tx, ty);
14771+
this.renderCount++;
14772+
};
14773+
return SetTransformNode;
14774+
})(sys.RenderNode);
14775+
sys.SetTransformNode = SetTransformNode;
14776+
egret.registerClass(SetTransformNode,'egret.sys.SetTransformNode');
14777+
})(sys = egret.sys || (egret.sys = {}));
14778+
})(egret || (egret = {}));
14779+
//////////////////////////////////////////////////////////////////////////////////////
14780+
//
14781+
// Copyright (c) 2014-2015, Egret Technology Inc.
14782+
// All rights reserved.
14783+
// Redistribution and use in source and binary forms, with or without
14784+
// modification, are permitted provided that the following conditions are met:
14785+
//
14786+
// * Redistributions of source code must retain the above copyright
14787+
// notice, this list of conditions and the following disclaimer.
14788+
// * Redistributions in binary form must reproduce the above copyright
14789+
// notice, this list of conditions and the following disclaimer in the
14790+
// documentation and/or other materials provided with the distribution.
14791+
// * Neither the name of the Egret nor the
14792+
// names of its contributors may be used to endorse or promote products
14793+
// derived from this software without specific prior written permission.
14794+
//
14795+
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
14796+
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
14797+
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
14798+
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
14799+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
14800+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
14801+
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
14802+
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
14803+
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
14804+
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14805+
//
14806+
//////////////////////////////////////////////////////////////////////////////////////
1468914807
//////////////////////////////////////////////////////////////////////////////////////
1469014808
//
1469114809
// Copyright (c) 2014-2015, Egret Technology Inc.
@@ -15343,20 +15461,7 @@ var egret;
1534315461
context.setTransform(m.a, m.b, m.c, m.d, m.tx + matrix.tx, m.ty + matrix.ty);
1534415462
}
1534515463
context.globalAlpha = renderAlpha;
15346-
switch (node.type) {
15347-
case 1 /* BitmapNode */:
15348-
this.renderBitmap(node, context);
15349-
break;
15350-
case 2 /* TextNode */:
15351-
this.renderText(node, context);
15352-
break;
15353-
case 3 /* GraphicsNode */:
15354-
this.renderGraphics(node, context);
15355-
break;
15356-
case 4 /* GroupNode */:
15357-
this.renderGroup(node, context);
15358-
break;
15359-
}
15464+
this.renderNode(node, context);
1536015465
node.needRedraw = false;
1536115466
}
1536215467
}
@@ -15593,6 +15698,12 @@ var egret;
1559315698
p.drawNodeToBuffer = function (node, buffer, matrix, forHitTest) {
1559415699
var context = buffer.context;
1559515700
context.setTransform(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
15701+
this.renderNode(node, context, forHitTest);
15702+
};
15703+
/**
15704+
* @private
15705+
*/
15706+
p.renderNode = function (node, context, forHitTest) {
1559615707
switch (node.type) {
1559715708
case 1 /* BitmapNode */:
1559815709
this.renderBitmap(node, context);
@@ -15606,6 +15717,12 @@ var egret;
1560615717
case 4 /* GroupNode */:
1560715718
this.renderGroup(node, context);
1560815719
break;
15720+
case 5 /* SetTransformNode */:
15721+
context.setTransform(node.drawData[0], node.drawData[1], node.drawData[2], node.drawData[3], node.drawData[4], node.drawData[5]);
15722+
break;
15723+
case 6 /* SetAlphaNode */:
15724+
context.globalAlpha = node.drawData[0];
15725+
break;
1560915726
}
1561015727
};
1561115728
/**
@@ -15726,20 +15843,7 @@ var egret;
1572615843
var length = children.length;
1572715844
for (var i = 0; i < length; i++) {
1572815845
var node = children[i];
15729-
switch (node.type) {
15730-
case 1 /* BitmapNode */:
15731-
this.renderBitmap(node, context);
15732-
break;
15733-
case 2 /* TextNode */:
15734-
this.renderText(node, context);
15735-
break;
15736-
case 3 /* GraphicsNode */:
15737-
this.renderGraphics(node, context);
15738-
break;
15739-
case 4 /* GroupNode */:
15740-
this.renderGroup(node, context);
15741-
break;
15742-
}
15846+
this.renderNode(node, context);
1574315847
}
1574415848
};
1574515849
/**

build/egret/egret.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/gui/gui.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12933,14 +12933,12 @@ var egret;
1293312933
this._strokeAlpha = 0;
1293412934
this._strokeWeight = 1;
1293512935
this.touchChildren = false;
12936+
this.$graphics = new egret.Graphics();
12937+
this.$graphics.$setTarget(this);
1293612938
}
1293712939
var d = __define,c=Rect,p=c.prototype;
1293812940
d(p, "graphics"
1293912941
,function () {
12940-
if (!this.$graphics) {
12941-
this.$graphics = new egret.Graphics();
12942-
this.$graphics.$setTarget(this);
12943-
}
1294412942
return this.$graphics;
1294512943
}
1294612944
);

build/gui/gui.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "egret",
3-
"version": "3.0.2",
3+
"version": "3.0.4",
44
"private": true,
55
"author": "egret-labs",
66
"scripts": {
@@ -12,7 +12,7 @@
1212
"i18n": "cn",
1313
"egret": {
1414
"registerClass": "egret",
15-
"typeScriptVersion": "1.7",
15+
"typeScriptVersion": "1.8",
1616
"modules": [
1717
{
1818
"name": "egret",

src/egret/player/nodes/GroupNode.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module egret.sys {
4545

4646
/**
4747
* 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。
48+
* 这里只是想清空绘制命令,因此不调用super
4849
*/
4950
public cleanBeforeRender():void {
5051
var data = this.drawData;

src/egret/player/nodes/RenderNode.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,15 @@ module egret.sys {
4848
/**
4949
* 组渲染节点
5050
*/
51-
GroupNode
51+
GroupNode,
52+
/**
53+
* 设置矩阵节点
54+
*/
55+
SetTransformNode,
56+
/**
57+
* 设置透明度节点
58+
*/
59+
SetAlphaNode
5260
}
5361

5462
/**
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//////////////////////////////////////////////////////////////////////////////////////
2+
//
3+
// Copyright (c) 2014-2015, Egret Technology Inc.
4+
// All rights reserved.
5+
// Redistribution and use in source and binary forms, with or without
6+
// modification, are permitted provided that the following conditions are met:
7+
//
8+
// * Redistributions of source code must retain the above copyright
9+
// notice, this list of conditions and the following disclaimer.
10+
// * Redistributions in binary form must reproduce the above copyright
11+
// notice, this list of conditions and the following disclaimer in the
12+
// documentation and/or other materials provided with the distribution.
13+
// * Neither the name of the Egret nor the
14+
// names of its contributors may be used to endorse or promote products
15+
// derived from this software without specific prior written permission.
16+
//
17+
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
18+
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19+
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20+
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
23+
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24+
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25+
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26+
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
//
28+
//////////////////////////////////////////////////////////////////////////////////////
29+
30+
module egret.sys {
31+
32+
/**
33+
* @private
34+
* 位图渲染节点
35+
*/
36+
export class SetAlphaNode extends RenderNode {
37+
38+
public constructor() {
39+
super();
40+
this.type = RenderNodeType.SetAlphaNode;
41+
}
42+
43+
/**
44+
* 绘制一次位图
45+
*/
46+
public setAlpha(alpha:number):void {
47+
if(this.drawData.length != 0) {
48+
this.drawData.length = 0;
49+
}
50+
this.drawData.push(alpha);
51+
this.renderCount++;
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)