您当前的位置: 首页 >  动画

鱼儿-1226

暂无认证

  • 0浏览

    0关注

    1100博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Spine学习二 -播放Spine动画

鱼儿-1226 发布时间:2020-07-15 16:15:59 ,浏览量:0

Spine学习二 -播放Spine动画

要想播放一个Spine动画,必须要在一个物体上绑定一个Spine播放的组件,这里暂时使用SkeletonAnimation组件。

然后就是编写动画的控制脚本。

这里提一个特性:

[SpineAnimation]:这个特性可以获取到SkeletonAnimation组件中绑定的 Spine资源的所有 动作名字,

[SpineAnimation]
public string runAnimationName;

 

其次,官方说了一个注意点,那就是最好不要在 Start()之前使用 AnimationState 和 Skeleton,因为这样没法保证他们的可靠性。

下面是获取 skeletonAnimationState的方法,见行8.

 1 public Spine.AnimationState spineAnimationState;
 2 public Spine.Skeleton skeleton;
 3 
 4 void Start () {
 5     // Make sure you get these AnimationState and Skeleton references in Start or Later.
 6     // Getting and using them in Awake is not guaranteed by default execution order.
 7     skeletonAnimation = GetComponent();
 8     spineAnimationState = skeletonAnimation.AnimationState;
 9     skeleton = skeletonAnimation.Skeleton;
10     StartCoroutine(DoDemoRoutine());
11     }

 

播放动画API:

1.AnimationState.SetAnimation() 这个API设置动画名字,并且从这个动画的开头开始播放。

2.AnimationState.AddAnimation() 将一个动画加入到队列,当上一个动画播放完毕时,这个动画就会播放。

3.skeleton.FlipX  翻转一个动画。

关注
打赏
1604459285
查看更多评论
立即登录/注册

微信扫码登录

0.0402s