一, 前言
Cocos Creator 3.7.3
二,Spine
import {Component, Node, sp, isValid, v3} from 'cc';
export class SpineView extends Component {
private spineAnim: sp.Skeleton;
private readonly EVENT_NAME: Array = ["dice1", "dice2", "dice3", "dice4", "dice5", "dice6"];
private readonly BONE_NAME: Array = ["dice1", "dice2", "dice3", "dice4", "dice5", "dice6"];
private readonly OPEN_EVENT: string = "open";
private readonly ANIM_NAME: string = "animation";
private boneArr: sp.spine.Bone[];
private images: Node[];
protected onLoad(): void {
this.spineAnim = this.node.getChildByName("Spine").getComponent(sp.Skeleton);
for (let i: number = 0服务器托管网; i
三,Animation
import {Component, Animation, AnimationState, isValid} from 'cc';
export class AnimView extends Component {
private anim: Animation;
private animState: AnimationState;
protected onLoad(): void {
this.anim = this.node.getChildByName("Anim").getComponent(Animation);
}
protected onEnable(): void {
this.listener(true);
}
protected onDisable(): void {
this.listener(false);
}
private listener(isAdd: boolean): void {
if (!isValid(this.node)) return;
if (isAdd) {
this.anim.on(Animation.EventType.FINISHED, this.onAnimComplete, this);
} else {
this.anim.off(Animation.EventType.FINISHED, this.onAnimComplete, this);
}
}
private onAnimComplete(event: string, date: AnimationState): void {
if (!isValid(this.node)) return;
switch (date.name) {
case "anim":
console.log(`Anim 播放完毕!`);
this.animState = this.anim.getState("anim");
if (this.animState) {
服务器托管网 console.log(`complete ${this.animState.isPlaying}`);
}
break;
}
}
public play(): void {
this.scheduleOnce(() => {
if (!isValid(this.node)) return;
console.log(`Anim 开始播放!!!!!!`);
this.anim.play("anim");
}, 6);
}
protected onDestroy(): void {
this.anim = null;
this.animState = null;
}
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
字符串表示的进制转换函数:stoi函数 int stoi( const std::string& str, std::size_t* pos = nullptr, int base = 10 ); 参数: str – 待转换的字符 pos – 其取值可…