fix:编辑器文件导入. add:example,runtime

This commit is contained in:
YipLee
2021-01-24 19:29:37 +08:00
parent c232a91a41
commit 91f4d8011b
214 changed files with 41328 additions and 120 deletions

View File

@@ -553,14 +553,32 @@ export default class FsmCtr extends cc.Component {
* 导入cocos animation文件
*/
public importAnim(animData: any) {
let x = Tool.randFloat(-this.MachineLayer.node.x - 100, -this.MachineLayer.node.x + 100);
let y = Tool.randFloat(-this.MachineLayer.node.y - 100, -this.MachineLayer.node.y + 100);
let unitState = this.MachineLayer.createState(cc.v2(x, y));
let state: State = unitState.state;
state.name = animData._name;
state.motion = animData._name;
state.speed = animData.speed;
state.loop = animData.wrapMode === cc.WrapMode.Loop;
if (animData instanceof Array) {
// 3.0 anim文件
animData.forEach((data) => {
if (!data.hasOwnProperty('_name')) {
return;
}
let x = Tool.randFloat(-this.MachineLayer.node.x - 100, -this.MachineLayer.node.x + 100);
let y = Tool.randFloat(-this.MachineLayer.node.y - 100, -this.MachineLayer.node.y + 100);
let unitState = this.MachineLayer.createState(cc.v2(x, y));
let state: State = unitState.state;
state.name = data._name;
state.motion = data._name;
state.speed = data.speed;
state.loop = data.wrapMode === cc.WrapMode.Loop;
});
} else {
// 2.x anim文件
let x = Tool.randFloat(-this.MachineLayer.node.x - 100, -this.MachineLayer.node.x + 100);
let y = Tool.randFloat(-this.MachineLayer.node.y - 100, -this.MachineLayer.node.y + 100);
let unitState = this.MachineLayer.createState(cc.v2(x, y));
let state: State = unitState.state;
state.name = animData._name;
state.motion = animData._name;
state.speed = animData.speed;
state.loop = animData.wrapMode === cc.WrapMode.Loop;
}
}
/**

View File

@@ -94,7 +94,7 @@ export default class Main extends cc.Component {
this.resetEditor();
this._editor.Parameters.import(data.parameters);
this._editor.Fsm.importProject(data);
} else if (data.skeleton && data.animations) {
} else if (data.animations) {
// 读取spine文件
this._editor.Fsm.improtSpine(data);
} else if (data.armature) {