123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import { SingleClass } from "./SingleClass";
- const { ccclass, property } = cc._decorator;
- export enum AnimType {
- Dog = 1,
- Daoju = 2,
- }
- @ccclass
- export default class SpinManager extends SingleClass {
- // public spSkeleton: sp.Skeleton = null;//动画
- // public currentAnimName: string = '';
- // 更换动画资源
- public ChangeSpineAnimation(node: cc.Node, path: string, animationName: string, isLoop: boolean, completeCallback: any = null, self: any = null, timeScale: number = 1){
- let spSkeleton = node.getComponent(sp.Skeleton);
- spSkeleton.loop = isLoop;
- spSkeleton.timeScale = timeScale;
- cc.assetManager.loadBundle("gameScene", (err,bundle)=>{
- bundle.load(path, sp.SkeletonData, function (err: Error, data: sp.SkeletonData) {
- if (err) {
- console.log("err", err);
- } else {
- spSkeleton.skeletonData = data;
- }
- });
- })
- }
- /**
- * 播放spin动画
- * @param animationName 动画名称
- * @param completeCallback 播放回调
- * @param isLoop 是否循环
- */
- public PlaySpinAnimation(node: cc.Node, animationName: string, isLoop: boolean, completeCallback: any = null, self: any = null, timeScale: number = 1) {
-
- let spinSkeleton = node.getComponent(sp.Skeleton);
- spinSkeleton.loop = isLoop;
- spinSkeleton.timeScale = timeScale;
- console.log("aaa----播放动画", animationName, isLoop);
- (completeCallback) ? spinSkeleton.setCompleteListener(completeCallback) : spinSkeleton.setCompleteListener(null);
- spinSkeleton.setAnimation(1, animationName, isLoop);
- // spinSkeleton.setEndListener(completeCallback);
- }
- public GetAnimationName(spinSkeleton: sp.Skeleton): string {
- return spinSkeleton.animation;
- }
- }
|