Commit 70d6d9a1 authored by 邱旭's avatar 邱旭

1

parent bcfa6a2b
This diff is collapsed.
import { GDispatcher } from "../../../libs/tc/util/GDispatcher";
import IconBase from "./IconBase";
export default class ActIcon {
private actIconsGroup;
private actsShowBtn;
private icons = {};
constructor(actsShowBtn, actIconGroup) {
this.actsShowBtn = actsShowBtn;
this.actIconsGroup = actIconGroup;
this.initUI();
this.initEvents();
}
public addActIcon(name: string, actIcon: IconBase) {
this.icons[name] = actIcon;
}
public removeActIcon(name:string){
if(this.icons[name]){
this.icons[name].destory();
delete this.icons[name];
}
}
public destory() {
for(let k in this.icons){
this.removeActIcon(this.icons[k]);
}
this.removeEvents();
}
private initUI() {
this.actIconsGroup.x = -999;
}
private updateActIcon(){
for(let k in this.icons){
if(this.icons[k].visible){
this.visible = true;
return;
}
}
this.visible = false;
}
public set visible(visible:boolean){
this.actsShowBtn.visible = visible;
this.actIconsGroup.visible = visible;
}
private onTap_actsShowBtn() {
this.actIconsGroup.visible = !this.actIconsGroup.visible;
this.actIconsGroup.x = 12.12;
if(this.actIconsGroup.visible == false) {
this.actIconsGroup.x = -999;
}
}
private initEvents() {
this.actsShowBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_actsShowBtn, this);
GDispatcher.addEvent('closeActBtn', this.onTap_actsShowBtn, this);
GDispatcher.addEvent('updateActIcon', this.updateActIcon, this);
}
private removeEvents() {
this.actsShowBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_actsShowBtn, this);
GDispatcher.removeEvent('closeActBtn', this.onTap_actsShowBtn, this);
GDispatcher.removeEvent('updateActIcon', this.updateActIcon, this);
}
}
\ No newline at end of file
......@@ -2,7 +2,6 @@ import IconBase from "./IconBase";
import PanelCtrl from "../../../libs/new_wx/ctrls/panelCtrl";
import { GDispatcher } from "../../../libs/tc/util/GDispatcher";
import { NetManager } from "../../../libs/tw/manager/NetManager";
import CutTimer from "../../CutTimer";
export default class HbRainIcon extends IconBase {
......@@ -56,7 +55,7 @@ export default class HbRainIcon extends IconBase {
GDispatcher.removeEvent('updateHbRainIcon', this.updateIcon, this);
}
protected destory() {
public destory() {
super.destory();
}
......
import { GDispatcher } from "../../../libs/tc/util/GDispatcher";
/**
* 地图页图标基类
* Created on 2019/10/25
......@@ -48,6 +50,11 @@ export default class IconBase {
this.iconBtn.visible = visible;
// this.iconTipsBg.visible = visible;
// this.iconTips.visible = visible;
GDispatcher.dispatchEvent('updateActIcon');
}
public get visible():boolean{
return this.iconGroup.visible;
}
public get position(): { x, y } {
......@@ -95,7 +102,7 @@ export default class IconBase {
this.iconBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchBtn, this);
}
protected destory() {
public destory() {
this.removeEvents();
}
......
......@@ -118,7 +118,7 @@ export default class ScratchIcon extends IconBase {
super.removeEvents();
}
protected destory() {
public destory() {
super.destory();
}
......
......@@ -61,7 +61,7 @@ export default class TurntableIcon extends IconBase {
GDispatcher.removeEvent('updateTurntableIcon', this.updateIcon, this);
}
protected destory() {
public destory() {
super.destory();
}
......
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