const ThemeManager = require('../utils/ThemeManger'); const NotiKey = require('../utils/GameEnum').GameNotificationKey; cc.Class({ extends: cc.Component, properties: { bgSprite: cc.Sprite, coverSprite: cc.Sprite, catNode: cc.Node, }, // LIFE-CYCLE CALLBACKS: init(cityId) { this.cityId = cityId; ThemeManager.setTopBgBuildSpriteFrame(cityId, this.bgSprite); ThemeManager.setTopCoverSpriteFrame(cityId, this.coverSprite); this.catNode.active = Global.devCityId === 1;//判断用户开发中的城市是否在第一个城市 }, initFriend(cityId) { this.cityId = cityId; ThemeManager.setTopBgBuildSpriteFrame(cityId, this.bgSprite); ThemeManager.setTopCoverSpriteFrame(cityId, this.coverSprite); this.catNode.active = this.cityId === 1;//判断好友开发中的城市是否在第一个城市 }, onLoad() { GameEvent.on(NotiKey.showCatFlyAnimation, this, this.catFlyAnimation); }, catFlyAnimation(endPosition) { this.scheduleOnce(() => { this.catNode.active = false; let position = this.catNode.parent.convertToWorldSpaceAR(this.catNode); position = cc.find('Canvas').convertToNodeSpaceAR(position); cc.loader.loadRes('./prefabs/cat_animation', cc.Prefab, (err, prefab) => { let flyCat = cc.instantiate(prefab); flyCat.parent = cc.find('Canvas'); flyCat.getComponent('FlyCat').fly(position, endPosition); }); }, 0.2); }, onDestroy() { GameEvent.off(NotiKey.showCatFlyAnimation, this); }, start() { }, // update (dt) {}, });