/************************************************************************************ * FileName : UICurrencyTips.ts * Description : 货币提示框 * Version : v1.0.0 * CreateTime : 2024-10-25 10:12:40 * Author : * Copyright (c) since 2024 * ============================================================== * Method Description: * * ============================================================== ************************************************************************************/ import {_decorator, Sprite, SpriteFrame, Vec3} from 'cc'; import {resLoader} from "db://assets/core_tgx/base/utils/ResLoader"; import {ModuleDef} from "db://assets/scripts/ModuleDef"; import {tgx_class} from "db://assets/core_tgx/base/ModuleContext"; import {tgxUIController} from "db://assets/core_tgx/tgx"; import {Layout_UICurrencyTips} from "db://assets/module_arean/scripts/Layout_UICurrencyTips"; import {GameUILayers} from "db://assets/scripts/GameUILayers"; const { ccclass, property } = _decorator; @tgx_class(ModuleDef.BASIC) export class UICurrencyTips extends tgxUIController { // 货币ID,根据货币ID前往不同的功能 private _currencyId : number = null; constructor() { super('prefabs/currencyTips', GameUILayers.POPUP, Layout_UICurrencyTips); } protected onCreated(params?: any) { let layout: Layout_UICurrencyTips = this.layout as Layout_UICurrencyTips; this._currencyId = params.currencyId; this._init(params.pos); this.onButtonEvent(layout.btnGo, this.clickGoBtn, this) this.onButtonEvent(layout.mask, ()=>{ this.close() }, this) } private _init(pos : Vec3) : void{ let layout: Layout_UICurrencyTips = this.layout as Layout_UICurrencyTips; let data = { icon : "", name : "金币", lab1 : "可以购买游戏内的道具", lab2 : "闯关获得" } let sp: SpriteFrame = resLoader.getSpriteFrame(`res/Image/Quality/${data.icon}`, ModuleDef.Arean); if (sp) layout.currencyIcon.getComponent(Sprite).spriteFrame = sp; layout.currencyName.string = data.name; layout.currencyLab1.string = data.lab1; layout.currencyLab2.string = data.lab2; // layout.bg.position = pos; } public clickGoBtn() : void{ if(this._currencyId == 1){ // 前往商店 }else if(this._currencyId == 2){ // 前往任务 }else if(this._currencyId == 3){ // 前往活动 }else if(this._currencyId == 4){ // 前往充值 }else if(this._currencyId == 5){ // 前往签到 }else if(this._currencyId == 6){ // 前往抽奖 } } }