Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加部分代码兼容 #731

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5,693 changes: 4,310 additions & 1,383 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "layaAir.config.js",
"scripts": {
"build": "cd src/publishTool&&cmd /k publish.bat",
"build": "cd src/publishTool&&./publish.sh",
"compile": "gulp LayaAirBuild",
"buildDoc": "cd src/generateDoc&&cmd /k run.bat"
},
Expand Down
40 changes: 20 additions & 20 deletions src/layaAir/laya/display/Graphics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ import { ILaya } from "../../ILaya";
*/
export class Graphics {
/**@internal */
_sp: Sprite|null = null;
_sp: Sprite | null = null;
/**@internal */
_one: any = null;
/**@internal */
_render: (sprite: Sprite, context: Context, x: number, y: number)=>void = this._renderEmpty;
_render: (sprite: Sprite, context: Context, x: number, y: number) => void = this._renderEmpty;
/**@private */
private _cmds: any[]|null = null;
private _cmds: any[] | null = null;
/**@private */
protected _vectorgraphArray: any[]|null = null;
protected _vectorgraphArray: any[] | null = null;
/**@private */
private _graphicBounds: GraphicsBounds|null = null;
private _graphicBounds: GraphicsBounds | null = null;
/**@private */
autoDestroy: boolean = false;

Expand Down Expand Up @@ -99,7 +99,7 @@ export class Graphics {
//TODO:内存回收all
if (recoverCmds) {
var tCmd = this._one;
if (this._cmds) {
if (this._cmds && this._cmds) {
var i: number, len = this._cmds.length;
for (i = 0; i < len; i++) {
tCmd = this._cmds[i];
Expand Down Expand Up @@ -205,7 +205,7 @@ export class Graphics {
* @param width (可选)宽度。
* @param height (可选)高度。
*/
drawImage(texture: Texture, x: number = 0, y: number = 0, width: number = 0, height: number = 0): DrawImageCmd|null {
drawImage(texture: Texture, x: number = 0, y: number = 0, width: number = 0, height: number = 0): DrawImageCmd | null {
if (!texture) return null;
if (!width) width = texture.sourceWidth;
if (!height) height = texture.sourceHeight;
Expand Down Expand Up @@ -253,7 +253,7 @@ export class Graphics {
* @param color (可选)颜色滤镜。
* @param blendMode (可选)混合模式。
*/
drawTexture(texture: Texture|null, x: number = 0, y: number = 0, width: number = 0, height: number = 0, matrix: Matrix|null = null, alpha: number = 1, color: string|null = null, blendMode: string|null = null, uv?: number[]): DrawTextureCmd|null {
drawTexture(texture: Texture | null, x: number = 0, y: number = 0, width: number = 0, height: number = 0, matrix: Matrix | null = null, alpha: number = 1, color: string | null = null, blendMode: string | null = null, uv?: number[]): DrawTextureCmd | null {
if (!texture || alpha < 0.01) return null;
if (!texture.getIsReady()) return null;
if (!width) width = texture.sourceWidth;
Expand Down Expand Up @@ -286,7 +286,7 @@ export class Graphics {
* @param texture 纹理。
* @param pos 绘制次数和坐标。
*/
drawTextures(texture: Texture, pos: any[]): DrawTexturesCmd|null {
drawTextures(texture: Texture, pos: any[]): DrawTexturesCmd | null {
if (!texture) return null;
return this._saveToCmd(Render._context.drawTextures, DrawTexturesCmd.create.call(this, texture, pos));
}
Expand All @@ -304,10 +304,10 @@ export class Graphics {
* @param color 颜色变换
* @param blendMode blend模式
*/
drawTriangles(texture: Texture, x: number, y: number, vertices: Float32Array, uvs: Float32Array, indices: Uint16Array, matrix: Matrix|null = null,
alpha: number = 1, color: string|null = null, blendMode: string|null = null, colorNum: number = 0xffffffff): DrawTrianglesCmd {
return this._saveToCmd(Render._context.drawTriangles,
DrawTrianglesCmd.create.call(this, texture, x, y, vertices, uvs, indices, matrix, alpha, color, blendMode, colorNum));
drawTriangles(texture: Texture, x: number, y: number, vertices: Float32Array, uvs: Float32Array, indices: Uint16Array, matrix: Matrix | null = null,
alpha: number = 1, color: string | null = null, blendMode: string | null = null, colorNum: number = 0xffffffff): DrawTrianglesCmd {
return this._saveToCmd(Render._context.drawTriangles,
DrawTrianglesCmd.create.call(this, texture, x, y, vertices, uvs, indices, matrix, alpha, color, blendMode, colorNum));
}

/**
Expand All @@ -321,7 +321,7 @@ export class Graphics {
* @param offset (可选)贴图纹理偏移
*
*/
fillTexture(texture: Texture, x: number, y: number, width: number = 0, height: number = 0, type: string = "repeat", offset: Point|null = null): FillTextureCmd|null {
fillTexture(texture: Texture, x: number, y: number, width: number = 0, height: number = 0, type: string = "repeat", offset: Point | null = null): FillTextureCmd | null {
if (texture && texture.getIsReady())
return this._saveToCmd(Render._context._fillTexture, FillTextureCmd.create.call(this, texture, x, y, width, height, type, offset || Point.EMPTY, {}));
else
Expand All @@ -332,7 +332,7 @@ export class Graphics {
* @internal
* 保存到命令流。
*/
_saveToCmd(fun: Function|null, args: any): any {
_saveToCmd(fun: Function | null, args: any): any {
if (this._sp) {
this._sp._renderType |= SpriteConst.GRAPHICS;
this._sp._setRenderType(this._sp._renderType);
Expand Down Expand Up @@ -392,7 +392,7 @@ export class Graphics {

/*** @private */
fillWords(words: any[], x: number, y: number, font: string, color: string): FillTextCmd {
return this._saveToCmd(Render._context.fillText, FillTextCmd.create.call(this, null, words, x, y, font || ILaya.Text.defaultFontStr(), color,'',0,null));
return this._saveToCmd(Render._context.fillText, FillTextCmd.create.call(this, null, words, x, y, font || ILaya.Text.defaultFontStr(), color, '', 0, null));
}

/*** @private */
Expand All @@ -411,8 +411,8 @@ export class Graphics {
* @param textAlign 文本对齐方式,可选值:"left","center","right"。
*/
strokeText(text: string, x: number, y: number, font: string, color: string, lineWidth: number, textAlign: string): FillTextCmd {
return this._saveToCmd(Render._context.fillText,
FillTextCmd.create.call(this, text, null, x, y, font || ILaya.Text.defaultFontStr(), null, textAlign, lineWidth, color));
return this._saveToCmd(Render._context.fillText,
FillTextCmd.create.call(this, text, null, x, y, font || ILaya.Text.defaultFontStr(), null, textAlign, lineWidth, color));
}

/**
Expand Down Expand Up @@ -549,7 +549,7 @@ export class Graphics {
* @param height (可选)显示图片的高度,设置为0表示使用图片默认高度。
* @param complete (可选)加载完成回调。
*/
loadImage(url: string, x: number = 0, y: number = 0, width: number = 0, height: number = 0, complete: Function|null = null): void {
loadImage(url: string, x: number = 0, y: number = 0, width: number = 0, height: number = 0, complete: Function | null = null): void {
var tex = ILaya.Loader.getRes(url) as Texture;
if (!tex) {
tex = new Texture();
Expand Down Expand Up @@ -621,7 +621,7 @@ export class Graphics {
* @param lineColor 线段颜色,或者填充绘图的渐变对象。
* @param lineWidth (可选)线段宽度。
*/
drawLines(x: number, y: number, points: any[], lineColor: any, lineWidth: number = 1): DrawLinesCmd|null {
drawLines(x: number, y: number, points: any[], lineColor: any, lineWidth: number = 1): DrawLinesCmd | null {
if (!points || points.length < 4) return null;
var offset = (lineWidth < 1 || lineWidth % 2 === 0) ? 0 : 0.5;
//TODO 线段需要缓存
Expand Down
4 changes: 3 additions & 1 deletion src/layaAir/laya/display/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class Node extends EventDispatcher {
if (this._children) {
//为了保持销毁顺序,所以需要正序销毁
for (var i: number = 0, n: number = this._children.length; i < n; i++) {
this._children[0].destroy(true);
this._children[0]&&this._children[0].destroy(true);
}
}
}
Expand Down Expand Up @@ -954,6 +954,8 @@ export class Node extends EventDispatcher {
if (this._components) {
for (var i: number = 0, n: number = this._components.length; i < n; i++) {
var comp: Component = this._components[i];
if (typeof componentType === "string" && comp.constructor.name === componentType)
return comp;
if (comp instanceof componentType)
return comp;
}
Expand Down
2 changes: 1 addition & 1 deletion src/layaAir/laya/display/Text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ export class Text extends Sprite {
* 文本边框背景颜色,以字符串表示。
*/
get borderColor(): string {
return ((<TextStyle>this._style)).borderColor;
return ((<TextStyle>this._style))&&((<TextStyle>this._style)).borderColor;
}

set borderColor(value: string) {
Expand Down