1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- 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,
- /// 增加钻石的
- diamond: 0,
- },
- // 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;
- },
- /// 初始化上次
- initAddDiamond(iconPath, desc, title, diamond) {
- this.diamond = diamond;
- this.init(iconPath, desc, title);
- },
- start () {
- },
- sureAction() {
- if (this.diamond > 0) {
- GameModule.userInfo.diamond += this.diamond;
- }
- GameModule.audioMng.playClickButton();
- let notificationStr = this._isBuyStar ? 'commAlert_BuyStar_hidden' : 'commAlert_hidden';
- GameEvent.fire(notificationStr);
- this.node.destroy();
- }
- // update (dt) {},
- });
|