123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- "use strict";
- cc._RF.push(module, 'fba44tQOWRGK5GR+oz1DtZ1', 'ZY_HomeScene');
- // Script/ZY_HomeScene.js
- "use strict";
- var _KurumiAD = _interopRequireDefault(require("./common/KurumiAD"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var ZYGameTool = require('GameTool');
- cc.Class({
- "extends": cc.Component,
- properties: {
- clickFlag: true,
- homeButtons: {
- type: cc.Button,
- "default": []
- },
- buttonsName: null,
- coinLabel: cc.Label,
- bgmClip: {
- type: cc.AudioClip,
- "default": null
- },
- //背景音乐
- logoNode: cc.Node,
- cactursNode: cc.Node,
- maskLayer: cc.Prefab,
- settingLayer: cc.Prefab,
- helpLayer: cc.Prefab,
- coinNode: cc.Node
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad: function onLoad() {
- // this.node.active = false;
- // ZYGameTool.getInstance().startDrawGame(function () {
- _KurumiAD["default"].instance.Init("4571759", //视频广告id
- "Rewarded_Android", //插评广告id
- "Interstitial_Android", function (data) {
- //初始化成功
- console.log('init the unity ad success');
- }, function (data) {
- //初始化失败
- console.log('init the unity ad fail');
- });
- this.node.active = true;
- this.setLocalDataItem();
- this.buttonsName = {
- redBagBtn: 0,
- giftBtn: 1,
- redBtn: 2,
- startBtn: 3,
- settingBtn: 4,
- helpBtn: 5,
- signBtn: 6
- };
- cc.debug.setDisplayStats(false); //首页按钮注册监听
- for (var i in this.homeButtons) {
- this.homeButtons[i].node.scale = 0;
- this.homeButtons[i].node.on("click", this.gameClickCall, this);
- }
- this.homeEffect(); // }.bind(this))
- },
- start: function start() {
- // ZYGameTool.getInstance().startDrawGame(function () {
- //是否已预加载资源
- if (isFirstInGame) {
- ZYGameTool.getInstance().loadSpriteFrame(function () {
- cc.director.preloadScene("mainScene");
- isFirstInGame = false;
- this.init();
- }.bind(this));
- } else {
- this.init();
- } // }.bind(this))
- // var hd = Math.PI / 180 * 30 ;
- // var jd = 180/Math.PI * hd;
- // console.log("--hd--: " , Math.sin(hd));
- // console.log("--jd--: " , Math.sin(jd));
- // this.privacyBtn.on('click',this.privacyEvent,this)
- // this.teamBtn.on('click',this.teamEvent,this)
- cc.find('Toggle/privacy', this.node).on('click', this.privacyEvent, this);
- cc.find('Toggle/team', this.node).on('click', this.teamEvent, this);
- },
- privacyEvent: function privacyEvent() {
- cc.sys.openURL('https://jetsbegin.today/privacy.html');
- },
- teamEvent: function teamEvent() {
- cc.sys.openURL('https://jetsbegin.today');
- },
- init: function init() {
- this.setCoinLabel(); //播放背景声音
- zy.playBgMusic(this.bgmClip, true);
- },
- /**
- * 初始化设置游戏所需本地化数据
- */
- setLocalDataItem: function setLocalDataItem() {
- coinNum = ZYGameTool.getInstance().getIntegerForKey(localDataItem.coinNum, 100); //默认金币
- playeSound = ZYGameTool.getInstance().getIntegerForKey(localDataItem.playeSound, 1); //音效开关
- playeMusic = ZYGameTool.getInstance().getIntegerForKey(localDataItem.playeMusic, 1); //背景音乐开关
- },
- /**
- *设置金币
- */
- setCoinLabel: function setCoinLabel() {
- if (coinNum === undefined || coinNum === 'NAN') coinNum = 0;
- this.coinLabel.string = coinNum;
- },
- /**
- * 首页的动画
- */
- homeEffect: function homeEffect() {
- var logoHeight = 1000;
- var initLogoHeight = this.logoNode.parent.y;
- {
- this.logoNode.y += logoHeight;
- this.cactursNode.y += logoHeight;
- } //logo
- {
- var actions = [];
- var ac1 = cc.moveBy(0.2, cc.v2(0, logoHeight * -1 - 50));
- var ac2 = cc.moveBy(0.1, cc.v2(0, 50));
- var ac3 = cc.scaleTo(0.1, 1, 0.6);
- var ac4 = cc.scaleTo(0.1, 1, 1);
- actions.push(ac1);
- actions.push(ac2);
- actions.push(ac3);
- actions.push(ac4); // actions2.concat(0,actions.length-1);
- var actions2 = [].concat(actions);
- console.log("actions2", actions2);
- this.logoNode.runAction(cc.sequence(cc.delayTime(0.2), cc.moveBy(0.2, cc.v2(0, logoHeight * -1 - 50)), cc.moveBy(0.1, cc.v2(0, 50)), cc.scaleTo(0.1, 1, 0.6), cc.scaleTo(0.1, 1, 1), cc.delayTime(1.5), cc.callFunc(function (node) {
- node.runAction(cc.repeatForever(cc.sequence(cc.rotateTo(1.5, 1), cc.rotateTo(1.5, -1))));
- }.bind(this), this.constructor)));
- this.cactursNode.runAction(cc.sequence(cc.delayTime(0.35 + 0.2), cc.moveBy(0.2, cc.v2(0, logoHeight * -1 - 50)), cc.moveBy(0.1, cc.v2(0, 50)), cc.scaleTo(0.1, 1, 0.6), cc.scaleTo(0.1, 1, 1), cc.delayTime(0.5), cc.callFunc(function (node) {
- node.runAction(cc.repeatForever(cc.sequence(cc.scaleTo(1.5, 1, 0.85), cc.scaleTo(1.5, 1, 1))));
- }.bind(this), this.constructor)));
- } //按钮统一动画
- {
- this.node.runAction(cc.sequence(cc.delayTime(0.6 + 0.2), cc.callFunc(function () {
- var dl = 0.05;
- for (var i in this.homeButtons) {
- this.homeButtons[i].node.runAction(cc.sequence(cc.delayTime(dl * i), cc.scaleTo(0.5, 1, 1)));
- }
- }.bind(this))));
- this.homeButtons[this.buttonsName.startBtn].node.runAction(cc.sequence(cc.delayTime(1.8), cc.callFunc(function (node) {
- node.runAction(cc.repeatForever(cc.sequence(cc.scaleTo(2.5, 0.85), cc.scaleTo(2.5, 1))));
- }.bind(this), this.homeButtons[this.buttonsName.startBtn])));
- }
- {
- this.homeButtons[this.buttonsName.redBtn].node.runAction(cc.sequence(cc.delayTime(1.8), cc.callFunc(function (node) {
- node.runAction(cc.repeatForever(cc.sequence(cc.spawn(cc.rotateTo(0.8, 7), cc.scaleTo(0.8, 0.9)), cc.spawn(cc.rotateTo(0.8, -7), cc.scaleTo(0.8, 1.0)))));
- }.bind(this), this.homeButtons[this.buttonsName.redBtn])));
- var finger = this.homeButtons[this.buttonsName.redBtn].node.parent.getChildByName("finger");
- finger.runAction(cc.sequence(cc.delayTime(1.8), cc.scaleTo(0.5, 0.6), cc.callFunc(function (node) {
- this.openBanner();
- node.runAction(cc.repeatForever(cc.sequence(cc.show(), cc.blink(2, 5), cc.delayTime(2), cc.hide(), cc.delayTime(5))));
- }.bind(this), finger)));
- }
- },
- openBanner: function openBanner() {// ZYGameTool.getInstance().OpenAd("banner", "banner");
- },
- gameClickCall: function gameClickCall(target) {
- var name = target.node.name;
- console.log("--name--: ", name);
- if (name === "startBtn") {
- this.gameStartClick();
- } else if (name === "helpBtn") {
- this.gameHelpClick(10);
- } else if (name === "redBtn") {
- this.gameRedClick();
- } else if (name === "settingBtn") {
- this.gameSettingClick();
- }
- },
- gameHelpClick: function gameHelpClick() {
- var helpLayer = cc.instantiate(this.helpLayer);
- helpLayer.parent = this.node;
- helpLayer.zIndex = 1000;
- },
- gameSettingClick: function gameSettingClick() {
- var settingNode = cc.instantiate(this.settingLayer);
- settingNode.parent = this.node;
- settingNode.zIndex = 1000;
- },
- gameRedClick: function gameRedClick(pos) {
- ZYGameTool.getInstance().OpenAd("home_lqjb", "video", function () {
- this.coinAction(10);
- coinNum += 10;
- this.setCoinLabel();
- ZYGameTool.getInstance().setIntegerForKey(localDataItem.coinNum, coinNum);
- console.log("---debug---成功---");
- }.bind(this), function () {
- console.log("---debug---失败---");
- }.bind(this));
- },
- coinAction: function coinAction(num) {
- var dl = 0.15;
- var bezier = [cc.v2(0, 0), cc.v2(-300, 100), cc.v2(this.coinNode.x - 60, this.coinNode.y)];
- for (var i = 0; i < num; i++) {
- var node = zy.getSprite("common/coin");
- node.setPosition(cc.v2(0, 0));
- node.scale = 0;
- node.zIndex = 100 - i;
- this.node.addChild(node);
- node.runAction(cc.speed(cc.sequence(cc.delayTime(dl * i), cc.scaleTo(0.2, 1, 1), cc.delayTime(0.1), cc.bezierTo(0.2, bezier), cc.fadeOut(0.05), cc.callFunc(function (node) {
- node.removeFromParent();
- }.bind(this), node)), num / 10));
- }
- },
- gameStartClick: function gameStartClick() {
- if (!this.clickFlag) return;
- zy.stopBgMusic();
- this.clickFlag = false;
- cc.director.loadScene("mainScene"); // this.node.runAction(cc.fadeOut(0.8));
- // this.node.runAction(cc.sequence(cc.delayTime(0.5), cc.callFunc(function () {
- // cc.director.loadScene("mainScene");
- // })));
- },
- // update (dt) {},
- onDestroy: function onDestroy() {
- //关闭所有音乐、音效
- cc.audioEngine.stopAll(); //移除所有事件监听
- cc.game.targetOff(this);
- }
- });
- cc._RF.pop();
|