import JiaZai from "./JiaZai"; import MapConroler from "./Map"; const { ccclass, property } = cc._decorator; @ccclass export default class ItemGuide extends cc.Component { static _instance: any; time: number = 0; //需要替换的三个道具节点 @property([cc.Node]) itemList: cc.Node[] = []; @property(cc.Node) itemGuide: cc.Node = null; //道具节点的图片 @property([cc.SpriteFrame]) itemSpriteList: cc.SpriteFrame[] = []; //飞的目标节点 @property([cc.Node]) targetNode: cc.Node[] = []; onLoad() { if (cc.fx.GameConfig.GM_INFO.level + 1 == 8) { this.itemList[0].getComponent(cc.Sprite).spriteFrame = this.itemSpriteList[0]; this.itemList[1].getComponent(cc.Sprite).spriteFrame = this.itemSpriteList[1]; this.itemList[2].getComponent(cc.Sprite).spriteFrame = this.itemSpriteList[2]; } else if (cc.fx.GameConfig.GM_INFO.level + 1 == 11) { this.itemList[0].getComponent(cc.Sprite).spriteFrame = this.itemSpriteList[3]; this.itemList[1].getComponent(cc.Sprite).spriteFrame = this.itemSpriteList[4]; this.itemList[2].getComponent(cc.Sprite).spriteFrame = this.itemSpriteList[5]; } else if (cc.fx.GameConfig.GM_INFO.level + 1 == 16) { this.itemList[0].getComponent(cc.Sprite).spriteFrame = this.itemSpriteList[6]; this.itemList[1].getComponent(cc.Sprite).spriteFrame = this.itemSpriteList[7]; this.itemList[2].getComponent(cc.Sprite).spriteFrame = this.itemSpriteList[8]; } } start() { } //关闭引导 closeGuide() { this.node.children.forEach((item) => { item.active = false; }) this.node.children[0].active = true; this.node.children[0].getComponent(cc.Sprite).spriteFrame = null; this.itemGuide.active = true; this.itemGuide.zIndex = 1000; //获取目标节点的位置并且转换到itemGuide的位置的层级 let index = 0; if (cc.fx.GameConfig.GM_INFO.level + 1 == 8) { index = 0; } else if (cc.fx.GameConfig.GM_INFO.level + 1 == 11) { index = 1; } else if (cc.fx.GameConfig.GM_INFO.level + 1 == 16) { index = 2; } let pos = this.targetNode[index].convertToWorldSpaceAR(cc.Vec3.ZERO); pos = this.node.convertToNodeSpaceAR(pos); this.itemGuide.zIndex = 1000; //同时改变大小和位置 cc.tween(this.itemGuide) .to(1.3, { scale: 0.3, position: pos }) // 同时执行 .call(() => { this.node.active = false; }) .start(); // } } // update (dt) {} }