Unity3D 2D Toolkit (之一)
来源:互联网 发布:传奇霸业轮回数据库 编辑:程序博客网 时间:2024/06/08 04:10
1.终于受不了Easymotion的各种突发情况和bug,一次次暗自下决心再也不用它了.说实话他的骨骼动画系统确实节省了不少资源,但是同样伴随各种问题,首先就是版本好久不更新了(Untiy4.**以上的版本会出现问题),自己的插件各版本间都不兼容.还有就是他的depth和挂在相机上的渲染,一不小心就出错,切图会有bug,动画帧元件在真实场景中丢失.更有甚者使用此插件更新Unity3D版本后制作的动画全乱.不说它的坏话了,制作出一款插件供开发者快速高效开发就已经值得大家心存感激了.
2.其他进入选择的有ex2D/2D toolkit.etc.查阅一些资料和分别进入各自的官网对比后觉得2D toolkit 编码手册更清晰一点,还有就是2d toolkit新版中添加tilemap,试了一些觉得这个功能特别赞,估计以后做拼接游戏特别方便,因此依然决然的选择了2d toolkit.
废话不多少了,进入正题.我使用的2d toolkit是1.91版本,为了净化国内开发环境,建议大家去官网或Unity3D商店购买正式版本(不喜勿喷,谢谢!)
初次接触到这个插件先看了官方的教程/Demo和网上的其它资料,发现资料不是太全.下面是官方教程的中文版本:
官方中文教程:http://download.csdn.net/detail/hiramtan/5241963
里面已经有的示例这里就不多少了,主要说一下使用2d toolkit时的心得.
1.怎样在动画播放结束时告诉程序此动画已经播放完毕(例如:播放人物死亡动画完成时通知程序已经结束该弹出结算面板了)怎样在动画播放到动画中间某几帧时告诉程序该执行其他逻辑了(例如:播放射击动画时播放完抬起手臂的帧后通知程序生成子弹逻辑后继续播放发射子弹的动画)
以下代码示例都是截取部分代码,其他部分需要自己添加!
因为定义动画是使用的是
enemyAnimation = GetComponent<tk2dAnimatedSprite>();
直接进入tk2dAnimatedSprite.cs查看源代码,发现有下面的两个事件
/// <summary>/// Animation complete delegate /// </summary>public delegate void AnimationCompleteDelegate(tk2dAnimatedSprite sprite, int clipId);/// <summary>/// Animation complete event. This is called when the animation has completed playing. Will not trigger on looped animations/// </summary>public AnimationCompleteDelegate animationCompleteDelegate;/// <summary>/// Animation event delegate./// </summary>public delegate void AnimationEventDelegate(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum);/// <summary>/// Animation event. This is called when the frame displayed has <see cref="tk2dSpriteAnimationFrame.triggerEvent"/> set./// The triggering frame is passed to the delegate, and the eventInfo / Int / Float can be extracted from there./// </summary>public AnimationEventDelegate animationEventDelegate;
或者是通过搜索官方编码目录中的tk2dAnimatedSprite,如下
在自己的代码中添加
case "Shoot": enemyAnimation.Play(enemyName + "Shoot"); enemyAnimation.animationCompleteDelegate = AnimationCompleteDelegate;//动画播放完成事件 enemyAnimation.animationEventDelegate = AnimationEventDelegate;//动画播发中的事件 break;
void AnimationCompleteDelegate(tk2dAnimatedSprite sprite, int clipId) { Debug.Log("动画播放结束"); } void AnimationEventDelegate(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum) { //动画播放中的事件 Debug.Log(frame.eventInfo); }
关于上面代码中的frame.eventInfo,在官网搜索tk2dSpriteAnimationFrame 便可以知道eventInfo就是播放动画时的输出信息(其他float,int变量同理).
然后在自己的动画中添加evenInfo,在需要添加eventInfo的帧上面双击即可,如下:
然后运行Unity3D测试是否成功.
如有任何建议请发邮件至hiramtan@qq.com
- Unity3D 2D Toolkit (之一)
- unity3d插件 2D Toolkit
- Unity3D 2D ToolKit --tk2dCamera
- Unity3d的2D Toolkit中tk2dUISoundItem使用注意事项
- Unity3D 2D ToolKit --为你的项目选择Camera
- 2D Toolkit 官方文档。
- 2d toolkit 创建button
- Shark翻译:2D Toolkit System Overview
- 2d toolkit qq群:250769158
- 2d toolkit字体描边
- 2D Toolkit官方教程翻译
- 2D Toolkit官方教程翻译
- Unity3D+免费工具开发2D游戏之一:工具和插件介绍
- Unity3D 2D动画插件EasyMotion2D (之一)Getting Start With EasyMotion2D
- Unity3d 2d设置
- Unity3D shatter toolkit研究
- Unity 3D引擎开发 2D Toolkit插件介绍
- Unity3d 2d动画组件
- 处理Oracle中杀不掉的锁
- 一手棋与一口气
- sharepoint 命令行安装、部署、删除wsp包
- 将分开的两个List合并成一个并保持其原来的顺序的两种方法
- 2013-03-18 0%-%33-0%-33%
- Unity3D 2D Toolkit (之一)
- file上传文件的获取方式.txt
- getimagesize
- MFC消息响应机制分析
- How to batch executing SQL statements on db2
- 32个SEO方法提高网站的流量:
- NET鼠标右键菜单JS[原]
- IOS 网络检测
- Java中的wait方法