zoukankan      html  css  js  c++  java
  • 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<SkeletonAnimation>();
     8     spineAnimationState = skeletonAnimation.AnimationState;
     9     skeleton = skeletonAnimation.Skeleton;
    10     StartCoroutine(DoDemoRoutine());
    11     }

    播放动画API:

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

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

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

  • 相关阅读:
    Python面向对象的魔术方法
    Python面向对象基础
    Python异常处理
    Python装饰器实现函数动态类型检查
    Python装饰器
    Python IO
    HTTP协议
    应用层常用协议
    读写分离
    MySQL优化三之MySQL配置
  • 原文地址:https://www.cnblogs.com/leiGameDesigner/p/9104969.html
Copyright © 2011-2022 走看看