-,-其实首先说明一点OTTween我觉得不够完美,甚至比不上iTween -。-
不过既然是自带的 速度还是可以的
特别注明一点,OT的动作是通过 点号 . 连接起来的
下面来看看代码:
public class CStar7_1 : MonoBehaviour
{
OTTween tween;
void OnMouseEnter()
{
if (tween!=null && tween.isRunning)
tween.Stop();
tween = new OTTween(GetComponent<OTSprite>(), 1f, OTEasing.ElasticOut).
Tween("size", new Vector2(80, 80)).
Tween("tintColor", new Color(0.5f + Random.value * 0.5f, 0.5f + Random.value * 0.5f, 0.5f + Random.value * 0.5f), OTEasing.StrongOut);
}
void OnMouseExit()
{
if (tween!=null && tween.isRunning)
tween.Stop();
tween = new OTTween(GetComponent<OTSprite>(), 1.5f, OTEasing.ElasticOut).
Tween("size", new Vector2(50, 50)).
Tween("tintColor", new Color(0.5f,0.5f,0.5f), OTEasing.StrongIn);
}
}
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
public class CStar7_2 : MonoBehaviour
{
OTTween runningTween = null;
OTTween tween = null;
void OnMouseEnter()
{
if ((tween!=null && tween.isRunning) || runningTween != null)
return;
tween = new OTTween(GetComponent<OTSprite>(), 2f, OTEasing.Linear).
Tween("size", new Vector2(250, 250)).
Tween("alpha", 1 , 0 , OTEasing.Linear);
tween.onTweenFinish = TweenFinish;
new OTTween(GetComponent<OTSprite>(), 1f, OTEasing.Linear).
Tween("tintColor", new Color(0.5f + Random.value * 0.5f, 0.5f + Random.value * 0.5f, 0.5f + Random.value * 0.5f), OTEasing.StrongOut);
}
void TweenFinish(OTTween tween)
{
if (tween != runningTween)
{
runningTween = new OTTween(GetComponent<OTSprite>(), .5f, OTEasing.Linear).
Tween("size", new Vector2(1, 1), new Vector2(50, 50)).
Tween("alpha", 0, 1, OTEasing.Linear);
new OTTween(GetComponent<OTSprite>(), .1f, OTEasing.Linear).
Tween("tintColor", new Color(0.3f, 0.3f, 0.3f), OTEasing.StrongOut);
runningTween.onTweenFinish = TweenFinish;
}
else
runningTween = null;
}
}
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
public class CExample7 : MonoBehaviour
{
int mode = 0;
float time = 0;
int easeIdx = 0;
OTEase[] easings = new OTEase[]
{
OTEasing.ElasticOut,
OTEasing.BounceOut,
OTEasing.StrongOut,
OTEasing.StrongIn,
OTEasing.BackOut,
OTEasing.BackIn,
OTEasing.SineOut,
OTEasing.Linear,
};
// Update is called once per frame
void Update () {
if (time == 0)
GameObject.Find("text-21").GetComponent<TextMesh>().text = "Next easing will be : " + easings[easeIdx].GetType().ToString();
time += Time.deltaTime;
if (time > 3)
{
MoveStars();
time = 0;
}
}
void MoveStars()
{
int idx = 1;
GameObject g = GameObject.Find("stars-"+idx);
while (g!=null)
{
new OTTween(g.transform,1.5f,easings[easeIdx]).TweenAdd("position",new Vector3((mode==0)?400:-400,0,0));
g = GameObject.Find("stars-" + (++idx));
}
mode = 1 - mode;
if (mode == 0)
{
easeIdx++;
if (easeIdx == easings.Length)
easeIdx = 0;
}
}
}