import gameUI from "../game/UIFace/gameUI"; import GameConfig from "./GameConfig"; const {ccclass, property} = cc._decorator; @ccclass export default class path1 extends cc.Component { private anim :cc.Animation = null; private path1data:cc.Vec3[] = []; public static instance:path1 = null; onLoad () { path1.instance = this; //获取当前节点上的动画组件 this.anim = this.node.getComponent(cc.Animation); // this.anim.play("path1_1"); } /**编辑路径 */ public changeLevelData(): void { this.path1data = []; if (this.anim == null) { return; } //获取动画片段 let clips = this.anim.getClips(); //获取当前片段 let clip = clips[gameUI.instance.myDataObj.LevelData.scene_path-1]; if (clip) { //获取贝塞尔曲线路径 let frames = clip.curveData.props.position; this.genpath1Data(frames); } } private genpath1Data(frames): void{ let bezier = []; //贝塞尔曲线定义四个点:起点、终点、两个相互分离中间控制点点 [begin, ctrl1, ctrl2, end] let begin = null, ctrl1 = null, ctrl2 = null, end = null; //遍历关键帧获取贝塞尔曲线 for(let i=0; i