import { GuideVO } from "../../data/module/GuideData"; /** * @description 新手引导 * @author 邹勇 */ const { ccclass, property } = cc._decorator; @ccclass export default class Guide extends cc.Component { @property({ type: cc.Node, displayName: "显示区域" }) node_display: cc.Node = null; @property({ type: cc.Node, displayName: "点击区域" }) node_click: cc.Node = null; @property({ type: cc.Node, displayName: "背景" }) node_bg: cc.Node = null; @property(cc.Node) node_block: cc.Node = null; @property({ type: cc.Sprite, displayName: "手指" }) node_finger: cc.Sprite = null; @property({ type: cc.Sprite, displayName: "头像" }) node_head: cc.Sprite = null; @property({ type: cc.Sprite, displayName: "形象" }) node_person: cc.Sprite = null; private guides: GuideVO[]; private crtStep: number; private crtGuide: GuideVO; onLoad() { } start() { if (gData.guideData.crtID == null) { this.node.destroy(); return; } this.guides = gData.guideData.getGuidesByID(gData.guideData.crtID); this.crtStep = -1; this.nextStep(); } private nextStep() { this.crtStep++; this.crtGuide = this.guides[this.crtStep]; this.updateGuide(); } private updateGuide() { if(this.crtGuide == null){ this.close(); } else{ this.reset(); if(this.crtGuide.display_rect != ""){ let arr = this.crtGuide.display_rect.split(":"); this.node_display.x = parseInt(arr[0]); this.node_display.y = parseInt(arr[1]); this.node_display.width = parseInt(arr[2]); this.node_display.height = parseInt(arr[3]); } else if(this.crtGuide.click_node != ""){ } if(this.crtGuide.finger != ""){ } } } clickBg() { console.log("clickBg"); if (this.crtGuide && this.crtGuide.click_node == "" && this.crtGuide.display_rect == "") { this.nextStep(); } } clickNodeClick() { console.log("clickNodeClick"); } private close(){ mk.guide.close(); this.node.destroy(); } }