iTween基础之Move(移动)
1,五种移动方法;2, 函数的基础属性及用法
原文地址:http://blog.csdn.net/dingkun520wy/article/details/50476864
iTween官网:http://itween.pixelplacement.com/index.php
1,五种移动方法
MoveTo:从原始位置移动到目标位置。
MoveFrom:从目标位置移动到原始位置。
MoveAdd:随时间移动游戏对象的位置,根据提供的量。
MoveBy:增加提供的坐标到游戏对象的位置。(与MoveAdd一样)
MoveUpdate:类似于MoveTo,在Update()或FixedUpdate()方法或循环环境中调用。提供每帧改变属性值的环境。不依赖于EasrType.
动画的方法一般有两种重载,
a,最小定制选项,只需要提供最少必需参数
//target:要移动的物体;position:要移动的位置;time:动画的运行的时间
public static void MoveUpdate(GameObject target, Vector3 position, float time);
b,完全定制选项,可定制所有的参数
//target:要移动的物体;args:定制的数组
public static void MoveUpdate(GameObject target, Hashtable args);
定制移动路径iTweenPath 详细讲解: http://blog.csdn.net/dingkun520wy/article/details/51075774
2, 函数的基础属性及用法
基础属性比较简单直接上代码
- void Start () {
- //键值对儿的形式保存iTween所用到的参数
- Hashtable args = new Hashtable();
- //这里是设置类型,iTween的类型又很多种,在源码中的枚举EaseType中
- //例如移动的特效,先震动在移动、先后退在移动、先加速在变速、等等
- args.Add("easeType", iTween.EaseType.easeInOutExpo);
- //移动的速度,
- //args.Add("speed",10f);
- //移动的整体时间。如果与speed共存那么优先speed
- args.Add("time",10f);
- //这个是处理颜色的。可以看源码的那个枚举。
- args.Add("NamedValueColor","_SpecColor");
- //延迟执行时间
- args.Add("delay", 0.1f);
- //是否让游戏对象始终面朝路径行进的方向,拐弯的地方会自动旋转。
- args.Add("orienttopath", true);
- //移动的过程中面朝一个点,当“orienttopath”为true时该参数失效
- args.Add("looktarget",Vector3.zero);
- //游戏对象看向“looktarget”的秒数。
- args.Add("looktime",1.1);
- //游戏对象移动的路径可以为Vector3[]或Transform[] 类型。可通过iTweenPath编辑获取路径
- Vector3[] testPath = { new Vector3(0, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 1), new Vector3(1, 1, 1), new Vector3(1, 5, 1) };
- args.Add("path", testPath);
- //是否移动到路径的起始位置(false:游戏对象立即处于路径的起始点,true:游戏对象将从原是位置移动到路径的起始点)
- args.Add("movetopath", false);
- //当包含“path”参数且“orienttopath”为true时,该值用于计算“looktarget”的值,表示游戏物体看着前方点的位置,(百分比,默认0.05)
- args.Add("lookahead",0.01);
- //限制仅在指定的轴上旋转
- args.Add("axis", "x");
- //是否使用局部坐标(默认为false)
- args.Add("islocal", false);
- //三个循环类型 none loop pingPong (一般 循环 来回)
- //args.Add("loopType", "none");
- //args.Add("loopType", "loop");
- args.Add("loopType", iTween.LoopType.pingPong);
- //处理移动过程中的事件。
- //开始发生移动时调用AnimationStart方法,5.0表示它的参数
- args.Add("onstart", "AnimationStart");
- args.Add("onstartparams", 5.0f);
- //设置接受方法的对象,默认是自身接受,这里也可以改成别的对象接受,
- //那么就得在接收对象的脚本中实现AnimationStart方法。
- args.Add("onstarttarget", gameObject);
- //移动结束时调用,参数和上面类似
- args.Add("oncomplete", "AnimationEnd");
- args.Add("oncompleteparams", "end");
- args.Add("oncompletetarget", gameObject);
- //移动中调用,参数和上面类似
- args.Add("onupdate", "AnimationUpdate");
- args.Add("onupdatetarget", gameObject);
- args.Add("onupdateparams", true);
- // x y z 标示移动的位置。
- args.Add("x",-5);
- args.Add("y",1);
- args.Add("z",1);
- //当然也可以写Vector3
- //args.Add("position",Vectoe3.zero);
- //最终让改对象开始移动
- iTween.MoveTo(btnBegin, args);
- }
- //对象移动中调用
- void AnimationUpdate(bool f)
- {
- Debug.Log("update :" + f);
- }
- //对象开始移动时调用
- void AnimationStart(float f)
- {
- Debug.Log("start :" + f);
- }
- //对象移动时调用
- void AnimationEnd(string f)
- {
- Debug.Log("end : " + f);
- }
iTween基础之Move(移动)的更多相关文章
- iTween基础之iTweenPath(自定义路径移动)
在游戏开发中经常会用到让一个游戏对象按照指定的路线移动,iTweenPath就提供了可视化的编辑路径功能. iTweenPath 下载地址: http://download.csdn.net/deta ...
- iTween基础之Color(变换颜色)
一.基础介绍:二.基础属性 原文地址: http://blog.csdn.net/dingkun520wy/article/details/51065275 一.基础介绍 ColorTo:从当前颜色变 ...
- iTween基础之Fade(淡入淡出)
一.基础介绍:二.基础属性 原文地址: http://blog.csdn.net/dingkun520wy/article/details/50923665 一.基础介绍 FadeTo:从当前透明度变 ...
- iTween基础之功能简介
一.iTween 介绍 .二.iTween 原理.三.iTween 下载.四.iTween 类介绍.五.主要功能介绍 原文地址:http://blog.csdn.net/dingkun520wy/ar ...
- iTween基础之CameraFade(摄像机淡入淡出)
一.基础介绍:二.基础属性 原文地址: http://blog.csdn.net/dingkun520wy/article/details/50896420 一.基础介绍 CameraTexture: ...
- iTween基础之Shake(摆动)
一.基础介绍:二.基础属性 原文地址 :http://blog.csdn.net/dingkun520wy/article/details/50836780 一.基础介绍 ShakePosition: ...
- iTween基础之Punch(摇晃)
一.基础介绍:二.基础属性 原文地址 : http://blog.csdn.net/dingkun520wy/article/details/50828042 一.基础介绍 PunchPosition ...
- iTween基础之Audio(音量和音调的变化)
一.基础介绍:二.基础属性 原文地址 : http://blog.csdn.net/dingkun520wy/article/details/50826033 一.基础介绍 AudioTo:改变声音的 ...
- iTween基础之Rotate(旋转角度)
一.基础介绍:二.基础属性 原文地址 :http://blog.csdn.net/dingkun520wy/article/details/50696489 一.基础介绍 RotateTo:旋转游戏物 ...
随机推荐
- 转 : React Native 开发之 IDE 选型和配置
转:https://mp.weixin.qq.com/s?__biz=MzA3ODg4MDk0Ng==&mid=2651112392&idx=1&sn=135e29ddde30 ...
- 动态创建DataTable总结
最简单的: DataTable dt = new DataTable(); dt.Columns.Add("id"); dt.Columns.Add("name" ...
- What Makes a Good Programmer Good?
I’ve worked with a lot of programmers over the years — some of them super amazing, and some distinct ...
- Process Stats:了解你的APP如何使用内存(转)
原文地址:http://android-developers.blogspot.com/2014/01/process-stats-understanding-how-your.html?m=1 原作 ...
- Part 14 Mathematical functions in sql server
Part 29 Mathematical functions in sql server
- JS中NULL和undifined区别及NULL的作用
1.博客地址:http://www.cnblogs.com/eastday/archive/2010/03/03/1677324.html 2.参考地址2:https://www.zhihu.com/ ...
- 第八篇、封装NSURLSession网络请求框架
主要功能介绍: 1.GET请求操作 2.POST请求操作 1.处理params参数(例如拼接成:usename="123"&password="123" ...
- iOS-Andriod百度地图仿百度外卖-饿了么-选择我的地址-POI检索/
http://zanderzhang.gitcafe.io/2015/09/19/iOS-Andriod百度地图仿百度外卖-饿了么-选择我的地址-POI检索/ 百度外卖选择送货地址: 饿了么选择送货地 ...
- C# 线程--第一单线程基础
概念 什么是进程? 当一个程序被打开运行时,它就是一个进程.在进程中包括线程,进程可以由一个或多个线程组成. 什么是线程? 线程是程序执行流的最小单元.一个标准的线程由线程ID,当前指令指针(PC), ...
- WCF之可靠性
可靠性会话: 端到端(多个点到点系统组成)的可靠性,基于消息,基于WS-*,可以跨平台. 在信道层创建可靠性会话,由两端的缓冲区进行可靠性管理(对消息进行排序后才发给服务器端,接收到消息后回发ACK. ...