// 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: { bottomMenuNode: { default: null, type: cc.Node, serializable: true, }, oldHeight: 0, }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, start() { //记录现在ui的bottom this.oldHeight = this.bottomMenuNode.getComponent(cc.Widget).bottom; // this.onPlayBannerAd(); }, // update (dt) {}, onCloseBannerAd() { this.bottomMenuNode.getComponent(cc.Widget).bottom = this.oldHeight; AD.closeAd(); }, onPlayBannerAd() { let that = this; AD.playAd((res) => { if (res.isPlay) { // console.log('that.oldHeight - resResize.height', that.oldHeight + res.height, that.oldHeight, res.height); that.bottomMenuNode.getComponent(cc.Widget).bottom = that.oldHeight + res.height * 2; } }, (resResize) => { }, (err) => { console.error('拉取广告失败'); that.bottomMenuNode.getComponent(cc.Widget).bottom = that.oldHeight; }) } });