"use strict";
cc._RF.push(module, 'ea278ndGXZHz7eTMGuXH+pC', 'game');
// scripts/game.js

"use strict";

// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        // foo: {
        //     // ATTRIBUTES:
        //     default: null,        // The default value will be used only when the component attaching
        //                           // to a node for the first time
        //     type: cc.SpriteFrame, // optional, default is typeof default
        //     serializable: true,   // optional, default is true
        // },
        // bar: {
        //     get () {
        //         return this._bar;
        //     },
        //     set (value) {
        //         this._bar = value;
        //     }
        // },
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start: function start() {
        BK.Advertisement.fetchBannerAd(function (retCode, msg, adBannerHandle) {
            if (retCode == 0) {
                //2.开发者 使用adBannerHanlde
                //2.1 决定是否展示
                adBannerHandle.show(function (succCode, msg, handle) {
                    if (succCode == 0) {
                        //
                        BK.Script.log(1, 1, "展示成功 msg:" + msg);
                    } else {
                        BK.Script.log(1, 1, "展示失败 msg:" + msg);
                    }
                });
                //2.2 开发者主动关闭广告。
                //adBannerHandle.close();
                //2.3 开发者监听事件
                adBannerHandle.onClickContent(function () {
                    //用户点击了落地页
                });

                //隐藏banner
                //adBannerHandle.setHidden(true);
                adBannerHandle.onClickClose(function () {
                    //用户点击了X关闭广告
                });
            } else {
                BK.Script.log(1, 1, "fetchBannerAd failed. retCode:" + retCode);
            }
        }.bind(this));
    }
}

// update (dt) {},
);

cc._RF.pop();