fix:编辑器文件导入. add:example,runtime
This commit is contained in:
12
examples/example3-0rc/assets/script/cases/animation.meta
Normal file
12
examples/example3-0rc/assets/script/cases/animation.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "b2e14807-4b9d-4cc6-b6a2-abe5ddb92a8c",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
63
examples/example3-0rc/assets/script/cases/animation/Sheep.ts
Normal file
63
examples/example3-0rc/assets/script/cases/animation/Sheep.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { Component, EventKeyboard, macro, misc, SystemEvent, systemEvent, _decorator } from 'cc';
|
||||
import AnimatorAnimation from '../../animator/AnimatorAnimation';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('Sheep')
|
||||
export class Sheep extends Component {
|
||||
|
||||
public _animator: AnimatorAnimation = null!;
|
||||
public speed: number = 0;
|
||||
|
||||
protected start() {
|
||||
this._animator = this.getComponent(AnimatorAnimation)!;
|
||||
|
||||
systemEvent.on(SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
|
||||
systemEvent.on(SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
|
||||
}
|
||||
|
||||
protected update(dt: number) {
|
||||
let delt = this._animator.curStateName === 'sheep_hit' ? 0 : this.speed * -this._animator.node.scale.x * dt;
|
||||
let x = misc.clampf(this._animator.node.position.x + delt, -1000, 1000);
|
||||
this._animator.node.setPosition(x, this._animator.node.position.y, this._animator.node.position.z);
|
||||
}
|
||||
|
||||
protected lateUpdate() {
|
||||
this._animator.setNumber('speed', this.speed);
|
||||
this._animator.manualUpdate();
|
||||
}
|
||||
|
||||
protected onDestroy() {
|
||||
systemEvent.off(SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
|
||||
systemEvent.off(SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
|
||||
}
|
||||
|
||||
private onKeyDown(event: EventKeyboard) {
|
||||
let code: number = event.keyCode;
|
||||
switch (code) {
|
||||
case macro.KEY.left:
|
||||
this._animator.node.setScale(1, this._animator.node.scale.y, this._animator.node.scale.z);
|
||||
this.speed = 100;
|
||||
break;
|
||||
case macro.KEY.right:
|
||||
this._animator.node.setScale(-1, this._animator.node.scale.y, this._animator.node.scale.z);
|
||||
this.speed = 100;
|
||||
break;
|
||||
case macro.KEY.k:
|
||||
this._animator.setTrigger('hit');
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private onKeyUp(event: EventKeyboard) {
|
||||
let code: number = event.keyCode;
|
||||
switch (code) {
|
||||
case macro.KEY.left:
|
||||
case macro.KEY.right:
|
||||
this.speed = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.21",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "af622b40-cc81-43ee-92f4-6914165ddaea",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
12
examples/example3-0rc/assets/script/cases/model.meta
Normal file
12
examples/example3-0rc/assets/script/cases/model.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "e3c34b9f-47cf-4a27-917d-5794cf452e3b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
14
examples/example3-0rc/assets/script/cases/model/Model.ts
Normal file
14
examples/example3-0rc/assets/script/cases/model/Model.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
import { Component, _decorator } from 'cc';
|
||||
import AnimatorAnimation from '../../animator/AnimatorAnimation';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('Model')
|
||||
export class Model extends Component {
|
||||
|
||||
private _animator: AnimatorAnimation = null!;
|
||||
|
||||
start() {
|
||||
this._animator = this.getComponent(AnimatorAnimation)!;
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.21",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "95984e29-62ff-4654-b528-f781f1adc24e",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Reference in New Issue
Block a user