123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- const DWTool = require("../utils/DWTool");
- const GameModule = require("../utils/GameModule");
- const ArtistManager = require('../utils/ArtistManager');
- cc.Class({
- extends: cc.Component,
- properties: {
- iconSprite: cc.Sprite,
- titleRichText: cc.RichText,
- descRichText: cc.RichText,
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- initBuyStar(imageId, desc, title, isRichText = false) {
- ArtistManager.loadStarAvatarSpriteFrame(imageId, this.iconSprite);
- if (isRichText) {
- this.descRichText.string = desc;
- } else {
- this.descRichText.string = `<color=#540904>${desc}</color>`;
- }
- this.titleRichText.string = `<b><color=#540904>${title}</c></b>`;
- this._isBuyStar = true;
- },
- init(iconPath, desc, title, isRichText = false) {
- DWTool.loadResSpriteFrame(iconPath)
- .then((spriteFrame) => {
- this.iconSprite.spriteFrame = spriteFrame;
- }).catch((err) => {
- console.log(err);
- });
- if (isRichText) {
- this.descRichText.string = desc;
- } else {
- this.descRichText.string = `<color=#540904>${desc}</color>`;
- }
- this.titleRichText.string = `<b><color=#540904>${title}</c></b>`;
- this._isBuyStar = false;
- },
- start () {
- },
- sureAction() {
- GameModule.audioMng.playClickButton();
- let notificationStr = this._isBuyStar ? 'commAlert_BuyStar_hidden' : 'commAlert_hidden';
- GameEvent.fire(notificationStr);
- this.node.destroy();
- }
- // update (dt) {},
- });
|