完善 docs

This commit is contained in:
SmallMain
2022-06-17 18:42:43 +08:00
parent a815401a2c
commit 142e19d075
45 changed files with 11534 additions and 149 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
{
"ver": "1.2.9",
"uuid": "03129ae1-98e5-4264-a51b-6f95f23d742a",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}

View File

@@ -0,0 +1,60 @@
const { ccclass, property } = cc._decorator;
@ccclass
export default class SpineSkin extends cc.Component {
@property(cc.Node)
addBoyBtn: cc.Node = null;
@property(cc.Node)
removeBoyBtn: cc.Node = null;
@property(cc.Node)
randomChangeBtn: cc.Node = null;
@property(cc.Node)
boy: cc.Node = null;
@property([cc.SpriteFrame])
heads: cc.SpriteFrame[] = [];
boys: cc.Node[] = [];
protected start(): void {
const boySpine = this.boy.getComponentInChildren(sp.Skeleton);
const newSkeletonData = boySpine.skeletonData.clone();
boySpine.skeletonData = newSkeletonData;
boySpine.animation = 'attack';
this.boys.push(this.boy);
this.addBoyBtn.on('click', () => {
const newBoy = cc.instantiate(this.boy);
const newBoySpine = newBoy.getComponentInChildren(sp.Skeleton);
boySpine.skeletonData = newBoySpine.skeletonData.clone();
boySpine.animation = 'attack';
this.boy.parent.addChild(newBoy);
newBoy.setPosition(this.boys[this.boys.length - 1].position);
newBoy.x += 100;
if (this.boys.length % 2 === 1) {
newBoy.getComponentInChildren(sp.Skeleton).setAnimationCacheMode(sp.Skeleton.AnimationCacheMode.PRIVATE_CACHE);
newBoy.getComponentInChildren(cc.Label).string = `Spine - Cache`;
}
this.boys.push(newBoy);
});
this.removeBoyBtn.on('click', () => {
if (this.boys.length > 1) {
this.boys[this.boys.length - 1].destroy();
this.boys.length -= 1;
}
});
this.randomChangeBtn.on('click', () => {
const boy = this.boys[this.boys.length - 1].getComponentInChildren(sp.Skeleton);
boy.setRegion('Head', 'Head', sp.SkeletonData.createRegion(this.heads[Math.floor(Math.random() * (this.heads.length))]));
});
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "27990422-853f-43c5-a2c7-52900cb9edef",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}