Commit cd469f27 authored by 邱旭's avatar 邱旭

1

parent acbce1cf
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<body> <body>
<div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main" <div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main"
data-orientation="auto" data-scale-mode="showAll" data-frame-rate="60" data-content-width="750" data-orientation="auto" data-scale-mode="showAll" data-frame-rate="60" data-content-width="750"
data-content-height="1624" data-multi-fingered="2" data-show-fps="false" data-show-log="true" data-content-height="1624" data-multi-fingered="2" data-show-fps="true" data-show-log="true"
data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9"> data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
</div> </div>
......
import ComponentBase from "../libs/new_wx/components/ComponentBase";
// // 用法示例:
// // 创建一个形状
// function getShape(x, y, w, h) {
// let newShape = new egret.Shape();
// newShape.graphics.beginFill(0x000000);
// newShape.graphics.drawRect(x, y, w, h); // 要镂空的大小和位置
// newShape.graphics.endFill();
// return newShape;
// }
//
// let shape = getShape(100, 100, 100, 100);
// let rMask = new ReverseMask(shape); // 创建一个ReverseMask
// this.addChild(rMask); // 加入场景
//
// // 使用缓动改变镂空位置
// // 使用缓动改变 hole 的位置或透明度,需要监听onChange设置为render函数
// egret.Tween.get(rMask.hole, {onChange: rMask.render}).to({x: 500, y: 500, alpha: 0.7}, 1000).call(() => {
// egret.Tween.get(rMask.hole, {onChange: rMask.render}).to({x: 200, y: 800, alpha: 1}, 1000).call(() => {
// rMask.setMask({x: 100, y: 100, w: 800, h: 800}); // 直接对mask进行重设
//
// let shape2 = getShape(300, 300, 150, 150);
// rMask.hole = shape2; // 直接对hole赋值进行重设
// });
// })
export default class ReverseMask extends ComponentBase {
private canvasW: number = 750 / window.innerWidth * window.innerWidth;
private canvasH: number = 750 / window.innerWidth * window.innerHeight;
private _shape: egret.Sprite;
private __mask: egret.Shape = new egret.Shape(); // 外面的遮罩
private _hole: egret.Shape;
public get hole() {
return this._hole;
}
public set hole(hole: egret.Shape) {
this._hole = hole;
this.setShape(this.rect);
}
private rect: { x, y, w, h };
constructor(hole: egret.Shape, rect?: { x, y, w, h }) {
super();
this._hole = hole;
this.rect = rect || {x: 0, y: 0, w: this.canvasW, h: this.canvasH};
this.setMask(rect);
}
public render = () => {
let renderTex = new egret.RenderTexture();
renderTex.drawToTexture(this._shape);
this['__shape'] = new egret.Bitmap(renderTex);
this.mask = this['__shape'];
!this['__shape'].parent && this.addChild(this['__shape']);
};
public setMask(rect?: { x, y, w, h }) {
this.__mask.graphics.clear();
this.__mask.graphics.beginFill(0x000000, 0.6);
if(rect) {
this.__mask.graphics.drawRect(rect.x, rect.y, rect.w, rect.h);
} else {
this.__mask.graphics.drawRect(0, 0, this.canvasW, this.canvasH);
}
this.__mask.graphics.endFill();
this.addChild(this.__mask);
this.setShape(rect);
}
private setShape(rect?: { x, y, w, h }) {
this._shape = new egret.Sprite();
this._shape.graphics.beginFill(0xffffff);
if(rect) {
this._shape.graphics.drawRect(rect.x, rect.y, rect.w, rect.h);
} else {
this._shape.graphics.drawRect(0, 0, this.canvasW, this.canvasH);
}
this._shape.graphics.endFill();
this._hole.blendMode = egret.BlendMode.ERASE;
this._shape.addChild(this._hole);
this.render();
}
}
\ No newline at end of file
import Panel from "../../../libs/new_wx/components/Panel"; import Panel from "../../../libs/new_wx/components/Panel";
import getSkinPath from "../../../libs/new_wx/utils/getSkinPath"; import getSkinPath from "../../../libs/new_wx/utils/getSkinPath";
import log = egret.log;
import { NetManager } from "../../../libs/tw/manager/NetManager"; import { NetManager } from "../../../libs/tw/manager/NetManager";
import PanelCtrl from "../../../libs/new_wx/ctrls/panelCtrl"; import PanelCtrl from "../../../libs/new_wx/ctrls/panelCtrl";
import Bitmap = egret.Bitmap;
export default class TaskCenter extends Panel { export default class TaskCenter extends Panel {
public closeBtn: eui.Button; public closeBtn: eui.Button;
...@@ -14,7 +12,7 @@ export default class TaskCenter extends Panel { ...@@ -14,7 +12,7 @@ export default class TaskCenter extends Panel {
let canvasW = 750 / window.innerWidth * window.innerWidth; let canvasW = 750 / window.innerWidth * window.innerWidth;
let canvasH = 750 / window.innerWidth * window.innerHeight; let canvasH = 750 / window.innerWidth * window.innerHeight;
// console.log('canvasW:' + canvasW + '\tcanvasH:' + canvasH); // console.log('canvasW:' + canvasW + '\tcanvasH:' + canvasH);
log({ console.log({
canvasW: canvasW, canvasW: canvasW,
canvasH: canvasH canvasH: canvasH
}); });
...@@ -74,7 +72,6 @@ class TaskCenterItem extends eui.ItemRenderer { ...@@ -74,7 +72,6 @@ class TaskCenterItem extends eui.ItemRenderer {
this.taskImg.source = this.data.icon; this.taskImg.source = this.data.icon;
this.title.text = this.data.taskTitle; this.title.text = this.data.taskTitle;
this.remark.text = this.data.remark; this.remark.text = this.data.remark;
this.setBtn(); // 设置按钮 this.setBtn(); // 设置按钮
} }
...@@ -108,7 +105,7 @@ class TaskCenterItem extends eui.ItemRenderer { ...@@ -108,7 +105,7 @@ class TaskCenterItem extends eui.ItemRenderer {
this.btnLabel.strokeColor = 0x1376df; this.btnLabel.strokeColor = 0x1376df;
this.btnGroup.addEventListener(egret.TouchEvent.TOUCH_TAP, () => { this.btnGroup.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
// 跳转任务链接 // 跳转任务链接
window.location.assign(this.data.appIncompletelink); window.open(this.data.appIncompletelink);
}, this); }, this);
} else { } else {
this.btnImg.source = 'TaskCenter_' + 'done' + 'Btn_png'; this.btnImg.source = 'TaskCenter_' + 'done' + 'Btn_png';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment