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

@@ -0,0 +1,7 @@
{
"ver": "1.0.1",
"uuid": "1aa00128-3386-4c14-8bd1-18e71df90d5b",
"isSubpackage": false,
"subpackageName": "",
"subMetas": {}
}

View File

@@ -0,0 +1,70 @@
import AnimatorAnimation from "../../animator/AnimatorAnimation";
import AnimatorStateLogic from "../../animator/core/AnimatorStateLogic";
import SheepHit from "./SheepHit";
import SheepIdle from "./SheepIdle";
import SheepRun from "./SheepRun";
const { ccclass, property } = cc._decorator;
@ccclass
export default class AnimationScene extends cc.Component {
@property(AnimatorAnimation) Animator: AnimatorAnimation = null;
public speed: number = 0;
protected onLoad() {
let map: Map<string, AnimatorStateLogic> = new Map();
map.set('sheep_idle', new SheepIdle());
map.set('sheep_run', new SheepRun());
map.set('sheep_hit', new SheepHit(this));
this.Animator.onInit(map);
cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
}
protected update(dt: number) {
let delt = this.Animator.curStateName === 'sheep_hit' ? 0 : this.speed * -this.Animator.node.scaleX * dt;
this.Animator.node.x = cc.misc.clampf(this.Animator.node.x + delt, -1000, 1000);
}
protected lateUpdate() {
this.Animator.setNumber('speed', this.speed);
this.Animator.manualUpdate();
}
protected onDestroy() {
cc.systemEvent.off(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
cc.systemEvent.off(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
}
private onKeyDown(event: cc.Event.EventKeyboard) {
let code: cc.macro.KEY = event.keyCode;
switch (code) {
case cc.macro.KEY.left:
this.Animator.node.scaleX = 1;
this.speed = 100;
break;
case cc.macro.KEY.right:
this.Animator.node.scaleX = -1;
this.speed = 100;
break;
case cc.macro.KEY.k:
this.Animator.setTrigger('hit');
default:
break;
}
}
private onKeyUp(event: cc.Event.EventKeyboard) {
let code: cc.macro.KEY = event.keyCode;
switch (code) {
case cc.macro.KEY.left:
case cc.macro.KEY.right:
this.speed = 0;
break;
default:
break;
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "14db7554-9454-4338-a487-150523459aca",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,25 @@
import AnimatorStateLogic from "../../animator/core/AnimatorStateLogic";
import AnimationScene from "./AnimationScene";
export default class SheepHit extends AnimatorStateLogic {
private _ctr: AnimationScene = null;
public constructor(ctr: AnimationScene) {
super();
this._ctr = ctr;
}
public onEntry() {
this._ctr.speed = 0;
cc.log('hit entry');
}
public onUpdate() {
this._ctr.speed = 0;
cc.log('hit update');
}
public onExit() {
cc.log('hit exit');
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "b1e94d2a-165f-4350-8035-c4e0ce55221b",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,16 @@
import AnimatorStateLogic from "../../animator/core/AnimatorStateLogic";
export default class SheepIdle extends AnimatorStateLogic {
public onEntry() {
cc.log('idle entry');
}
public onUpdate() {
cc.log('idle update');
}
public onExit() {
cc.log('idle exit');
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "ffe798df-0253-48ab-bdcc-31b7c2ddc3c7",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,16 @@
import AnimatorStateLogic from "../../animator/core/AnimatorStateLogic";
export default class SheepRun extends AnimatorStateLogic {
public onEntry() {
cc.log('run entry');
}
public onUpdate() {
cc.log('run update');
}
public onExit() {
cc.log('run exit');
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "249d7306-946e-4f59-9446-b6ecc1d456a4",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,7 @@
{
"ver": "1.0.1",
"uuid": "fcde15b6-7401-4e97-8d61-f6f7eab6f002",
"isSubpackage": false,
"subpackageName": "",
"subMetas": {}
}

View File

@@ -0,0 +1,95 @@
import AnimatorCustomization from "../../animator/AnimatorCustomization";
import { AnimationPlayer } from "../../animator/core/AnimatorBase";
const { ccclass, property } = cc._decorator;
@ccclass
export default class CustomizationScene extends cc.Component implements AnimationPlayer {
@property(cc.Node) Cube: cc.Node = null;
private _animator: AnimatorCustomization = null;
private _curTween: cc.Tween = null;
private _call: () => void = null;
private _traget: any = null;
protected onLoad() {
this._animator = this.Cube.getComponent(AnimatorCustomization);
// 自定义动画播放必须要将实现了AnimationPlayer接口的对象传入
this._animator.onInit(this);
this.node.on(cc.Node.EventType.TOUCH_START, () => { this._animator.setTrigger('next'); }, this);
}
private move(dur: number, pos: cc.Vec3, loop: boolean) {
if (loop) {
this._curTween = cc.tween(this.Cube)
.repeatForever(
cc.tween()
.to(dur, { position: pos })
.call(() => {
this._call.call(this._traget);
})
)
.start();
} else {
this._curTween = cc.tween(this.Cube)
.to(dur, { position: pos })
.call(() => {
this._call.call(this._traget);
})
.start();
}
}
/**
* - 实现接口 AnimationPlayer
* 设置动画播放结束的回调
*/
public setFinishedCallback(callback: () => void, target: any): void {
this._call = callback;
this._traget = target;
}
/**
* - 实现接口 AnimationPlayer
* 播放动画
*/
public playAnimation(animName: string, loop: boolean): void {
this._curTween && this._curTween.stop();
if (animName === 'idle') {
if (loop) {
this._curTween = cc.tween(this.Cube)
.repeatForever(
cc.tween()
.to(1, { scale: 2 })
.to(1, { scale: 0.5 })
.call(() => {
this._call.call(this._traget);
})
)
.start();
} else {
this._curTween = cc.tween(this.Cube)
.to(1, { scale: 2 })
.to(1, { scale: 0.5 })
.call(() => {
this._call.call(this._traget);
})
.start();
}
} else if (animName === 'move1') {
this.move(2, cc.v3(500, 500, 0), loop);
} else if (animName === 'move2') {
this.move(4, cc.v3(0, 0, 0), loop);
}
}
/**
* - 实现接口 AnimationPlayer
* 缩放动画播放速率
*/
public scaleTime(scale: number): void {
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "4ecb8927-f33a-4833-9ffb-8e38c1193687",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,7 @@
{
"ver": "1.0.1",
"uuid": "19bb3ee7-3033-4cb7-85ea-59d38ab1797f",
"isSubpackage": false,
"subpackageName": "",
"subMetas": {}
}

View File

@@ -0,0 +1,12 @@
import AnimatorDragonBones from "../../animator/AnimatorDragonBones";
const {ccclass, property} = cc._decorator;
@ccclass
export default class DragonBonesScene extends cc.Component {
@property(AnimatorDragonBones) Animator: AnimatorDragonBones = null;
protected onLoad() {
this.node.on(cc.Node.EventType.TOUCH_START, () => { this.Animator.setTrigger('next'); }, this);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "46c5fdeb-47df-4174-bfe0-f233c54da45b",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,7 @@
{
"ver": "1.0.1",
"uuid": "56d84939-6606-4c19-be06-e9583942e3d2",
"isSubpackage": false,
"subpackageName": "",
"subMetas": {}
}

View File

@@ -0,0 +1,64 @@
import AnimatorSpine from "../../animator/AnimatorSpine";
import AnimatorSpineSecondary from "../../animator/AnimatorSpineSecondary";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SpineScene extends cc.Component {
@property(sp.Skeleton) SpineBoy: sp.Skeleton = null;
private _updateSpeed: boolean = false;
private _speed: number = 0;
private _animatorMain: AnimatorSpine = null;
private _animatorSecondary: AnimatorSpineSecondary[] = [];
protected onLoad() {
this._animatorMain = this.SpineBoy.getComponent(AnimatorSpine);
this._animatorMain.onInit((fromState: string, toState: string) => {
cc.log(`state change: ${fromState} -> ${toState}`);
});
this._animatorSecondary = this.SpineBoy.getComponents(AnimatorSpineSecondary);
cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
}
protected update(dt: number) {
this._speed = this._updateSpeed ? Math.min(5, this._speed + dt) : Math.max(0, this._speed - dt * 2);
this._animatorMain.setNumber('speed', this._speed);
}
protected onDestroy() {
cc.systemEvent.off(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
cc.systemEvent.off(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
}
private onKeyDown(event: cc.Event.EventKeyboard) {
let code: cc.macro.KEY = event.keyCode;
switch (code) {
case cc.macro.KEY.left:
case cc.macro.KEY.right:
this._updateSpeed = true;
break;
case cc.macro.KEY.space:
this._animatorMain.autoTrigger('jump');
break;
case cc.macro.KEY.k:
this._animatorSecondary[0].autoTrigger('shoot');
default:
break;
}
}
private onKeyUp(event: cc.Event.EventKeyboard) {
let code: cc.macro.KEY = event.keyCode;
switch (code) {
case cc.macro.KEY.left:
case cc.macro.KEY.right:
this._updateSpeed = false;
break;
default:
break;
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "1810c37f-1e5a-41ec-b2ba-e78ac9b155e0",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}