import { Color, SpriteAtlas, _decorator } from 'cc'; import { AudioID } from '../../framework/config/AudioConf'; import { ViewID } from '../../framework/config/LayerConf'; import { Framework } from '../../framework/Framework'; import { BaseView } from '../../framework/layer/BaseView'; const { ccclass, property } = _decorator; @ccclass('MainUI') export class MainUI extends BaseView { /** 菜单图集 */ private _menuBottomAtlas: SpriteAtlas; /** 菜单栏 */ private _menuNameArray: Array = ['Welfare', 'Games', 'OpenBets', 'Me']; /** 选中 */ private _selected: string = 'Games'; /** 状态 */ private _isLoaded: boolean = false; onLoad() { super.onLoad(); } onDestroy() { super.onDestroy(); Framework.event.removeEvent(this); } onOpen() { //加载菜单 this.load('package', 'texture/hall/Menu_Bottom/Menu_Bottom', SpriteAtlas, (res: SpriteAtlas) => { this._menuBottomAtlas = res; this._isLoaded = true; this.updateSelectMenu(); }) } onClose() { } onShow() { this._ui_opacity.opacity = 255; this.node.setPosition(0, 0); } onHide() { this._ui_opacity.opacity = 0; this.node.setPosition(0, -5000); } private onTouchButton(event: Event, customStr) { // let target: any = event.target; if (!this._isLoaded) { return; } if (customStr != 'Games') { Framework.tips.setTips('Not yet available'); return; } this._selected = customStr; this.updateSelectMenu(); } updateSelectMenu() { for (let i = 0; i < this._menuNameArray.length; i++) { const name = this._menuNameArray[i]; if (this._selected == name) { this.Sprite[name].spriteFrame = this._menuBottomAtlas.spriteFrames[name + '_' + 'Yellow']; this.Label[name].color = new Color(244, 184, 12); this.updateSelectInfo(); } else { this.Sprite[name].spriteFrame = this._menuBottomAtlas.spriteFrames[name + '_' + 'Grey']; this.Label[name].color = new Color(120, 123, 130); } } } updateSelectInfo() { } }