话说博客传图也太麻烦了吧,一个一个文件一个一个传。。。。为什么不能直接粘贴了,自动上传呢。。。
刚直接粘贴了,结果一张图没有,又重新截一次图,在传了一次。。。真是太**了
好了,吐槽完了,开始博客吧
使用2DToolkit插件制作2D精灵动画
1.导入2DToolKit包
2.创建 Sprite Collection
必须重新命名
点击 open editor,将所用的精灵动画图片添加到collection,完成后 commit
3. 创建Sprite Animation
点击 open editor ,创建clip,添加精灵图片到动画桢,commit
4.创建精灵
在Hierarchy 中创建 sprite with animator
在inspector 中 将 之前创建的 sprite collection 绑定到精灵
5. 编写脚本
最后一步编写代码,让我们的小伙伴动起来,
给精灵创建一个脚本,代码如下:
public class RoleController : MonoBehaviour { ///role ani private tk2dSpriteAnimator roleAnimator; void Start () { roleAnimator = GetComponent<tk2dSpriteAnimator>(); } void Update () { if(Input.GetKeyDown(KeyCode.A)) { roleAnimator.Play("run_left"); } if(Input.GetKeyDown(KeyCode.D)) { roleAnimator.Play("run_right"); } } }
运行,然后按下A或D,可以看到 我们的小伙伴动起来了,有木有!!!
国际惯例,上效果图: