Spring774
2025-10-27 a621979f62588ed1a899d17c937dc3aee8670ec1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
 
import PromoFetchFB from "./PromoFetchFB";
 
const { ccclass, property } = cc._decorator;
 
/**
 * 推广自家游戏
 */
@ccclass
export class PromoShowFB extends cc.Component {
 
    @property(cc.Button)
    promoButton: cc.Button = null;
    @property(cc.Sprite)
    promoSprite: cc.Sprite = null;
 
    promoIndex: number = -1;
    onLoad() {
        this.promoButton.node.active = false;
    }
 
    onEnable() {
        this.schedule(this.changePromoImage, 10, cc.macro.REPEAT_FOREVER, 1);//10秒check一次
    }
 
    onDisable() {
        this.unschedule(this.changePromoImage);
    }
 
    startPromoButtonAction() {
        this.promoButton.node.stopAllActions();
        this.promoButton.node.runAction(
            cc.repeatForever(
                cc.sequence(
                    cc.scaleTo(0.5, 1),
                    cc.scaleTo(0.3, 0.95)
                )
            )
        );
    }
 
    changePromoImage() {
        if (PromoFetchFB.ins && PromoFetchFB.ins.PromoSpriteFrames.length > 0) {
            if (!this.promoButton.node.active) {
                this.promoButton.node.active = true;
                this.startPromoButtonAction();
            }
 
            this.promoIndex++;
            if (this.promoIndex >= PromoFetchFB.ins.PromoSpriteFrames.length) {
                this.promoIndex = 0;
            }
 
            this.promoSprite.spriteFrame = PromoFetchFB.ins.PromoSpriteFrames[this.promoIndex].spriteFrame;
        } else {
            this.promoButton.node.active = false;
        }
    }
 
 
    onClickPromo() {
        let appid = PromoFetchFB.ins.PromoSpriteFrames[this.promoIndex].appid;
 
        if (typeof FBInstant !== 'undefined') {
            FBInstant.switchGameAsync(appid);
        }
        else {
            cc.log("点击跳转 -> " + appid);
        }
    }
 
    // update (dt) {}
}