123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- const DWTool = require('../utils/DWTool')
- const GameModule = require('../utils/GameModule')
- const WeChat = require('../net/WeChat');
- cc.Class({
- extends: cc.Component,
- properties: {
-
- content: cc.Node,
- coinRichText: cc.RichText,
-
- watchVideoRichText: cc.RichText,
-
- shareRichText: cc.RichText,
- secretarySprite: cc.Node,
- grossIncome: {
- get: function() {
- if (this._grossIncome) {
- this._grossIncome = 0;
- }
- return this._grossIncome;
- },
- set: function (value) {
- this._grossIncome = value;
- this.setCoinRichText(value);
- this.setWatchVideoRichText(value);
- this.setShareVideoRichText(value);
- }
- }
- },
- // LIFE-CYCLE CALLBACKS:
- init(grossIncome) {
- this.grossIncome = grossIncome;
- },
- onLoad () {
- },
- start () {
- this.content.scaleX = 0;
- this.content.scaleY = 0;
- this.content.runAction(cc.scaleTo(0.35, 1, 1).easing(cc.easeBackOut()));
- this.secretarySprite.runAction(cc.moveBy(0.3, cc.v2(400, 0)));
- },
- dismiss() {
- let finish = cc.callFunc(() => {
- this.node.destroy();
- }, this);
- let sequence = cc.sequence(cc.scaleTo(0.2, 0, 0).easing(cc.easeBackIn()), finish)
- this.content.runAction(sequence);
- },
- watchVideo() {
- this.dismiss();
- },
- share() {
- WeChat.inviteFriend(ShareAction.ADD_FRIEND, () => {
- GameModule.userInfo.grossIncome += this.grossIncome * 3;
- this.dismiss();
- }, () => {
- this.dismiss();
- });
- },
- setCoinRichText(coin) {
- this.coinRichText.string = `<img src='alert_coin'/><outline color=#ffffff width=4><b><color=#009227> ${DWTool.coinParse(coin)}</c></b></outline>`;
- },
- setWatchVideoRichText(coin) {
- this.watchVideoRichText.string = `<img src='alert_coin'/><color=#ffffff> ${DWTool.coinParse(coin * 2)}</c>`;
- },
- setShareVideoRichText(coin) {
- this.shareRichText.string = `<img src='alert_coin'/><color=#ffffff> ${DWTool.coinParse(coin * 3)}</c>`;
- },
- // update (dt) {},
- });
|