iTween:Getting Started!

Installation 安装

iTween can be used with all scripting languages that Unity supports including JavaScript, C# and Boo. To install iTween

create a folder named "Plugins" in your project's assets (if you are using C# the location of iTween does not matter as

long as it is inside your assets folder).
iTwen可以和Unity所支持的所有脚本语言(包括JavaScript, C# and Boo)一起使用。在项目的assets文件夹下面创建一个Plugins文件夹,将

iTween安装在这个文件夹下。如果你使用C#,可以把iTween安装在assets文件夹下的任意位置。 这里的iTween可以只是iTween.cs这个脚本

Hello World!

With iTween you can move, rotate, shake, punch, fade, scale, control audio, fade cameras and more! iTween is a static class

which is a class that allows you to run methods on it, or call its properties, but never needs to be instantiated or

created. As a user of iTween this means you never create a new instance of iTween; you simply ask it to do things for you.
使用iTween你可以移动,旋转,摇晃, punch, fade, 缩放, control audio, fade cameras and more!iTween是一个静态类,允许你运行它的方法或者调用它的属性。但是你从来都不需要创建一个iTween的实例。直接用类名iTween调用它的方法和属性就可以了。
In its simplest form you can ask iTween to animate with limited parameters allowing defaults to be filled in to save typing

at the loss of customization. For example, to have iTween animate the position of something from its current position to a

new position over the span of 2 seconds:
最简单的方式是:用最少的参数来模拟动画,其余的参数为默认值。如•MoveTo(GameObject target, Vector3 position, float time)
iTween.MoveTo(gameObject,Vector3(2,0,0),2);

iTween also offers the ability to create animations with full control over things such as delay, looping, callback

functions and much more. To use iTween's more robust features you must provide the parameters you would like in the form of

a Hashtable.
iTween也提供对动画的全面控制,如使用delay,loopig,callback functions或者更多参数。要用到Hashtable,C#中有两种方法:
方法一:Hashtable ht = new Hashtable();
 
void Awake(){
 ht.Add("x",3);
 ht.Add("time",4);
 ht.Add("delay",1);
 ht.Add("onupdate","myUpdateFunction");
 ht.Add("looptype",iTween.LoopType.pingPong);
}

void Start(){
 iTween.MoveTo(gameObject,ht);
}

javascript中这样:iTween.MoveTo(gameObject,{"x":3,"time":4,"delay":1,"onupdate","myUpdateFunction","looptype","pingpong"});
方法二:此方法,各种语言通用。iTween.Hash()里,一个字符串做参数名,后面跟上它的值。
Or you can use iTween's Hash() method to make things consistent across all language and to allow calls to be done in 1 line

in C#. The Hash() method requires alternating entries of a parameter name as a string followed by its value:
iTween.MoveTo(gameObject,iTween.Hash

("x",3,"time",4,"delay",1,"onupdate","myUpdateFunction","looptype",iTween.LoopType.pingPong)); 

你可能感兴趣的:(iTween:Getting Started!)