码迷,mamicode.com
首页 > 其他好文 > 详细

为 iTween 指定特定的回调 : onupdate, oncomplete ...

时间:2014-07-14 23:05:31      阅读:323      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   for   

问题地址:Specifying a delegate for the value of onupdate in iTween

 

1、找到 void CallBack

2、修改以下代码:

void CallBack(string callbackType){
    if (tweenArguments.Contains(callbackType) && !tweenArguments.Contains("ischild")) {
        //establish target:
        GameObject target;
        if (tweenArguments.Contains(callbackType+"target")) {
            target=(GameObject)tweenArguments[callbackType+"target"];
        }else{
            target=gameObject;    
        }
        
        //throw an error if a string wasn‘t passed for callback:
        if (tweenArguments[callbackType].GetType() == typeof(System.String)) {
            target.SendMessage((string)tweenArguments[callbackType],(object)tweenArguments[callbackType+"params"],SendMessageOptions.DontRequireReceiver);
        }else if (tweenArguments[callbackType] is Action) {
            ((Action)tweenArguments[callbackType]).Invoke();
        }else if (tweenArguments[callbackType] is Action<object>) {
            ((Action<object>)tweenArguments[callbackType]).Invoke((object)tweenArguments[callbackType + "params"]);
        }else{
            Debug.LogError("iTween Error: Callback method references must be passed as a String!");
            Destroy (this);
        }
    }
}

3、用法如下:

iTween.MoveTo(gameObject, iTween.Hash(
    "x", x,
    "y", y,
    "time", t,
    "easeType", iTween.EaseType.easeInCubic, 
    "onComplete", (Action)Landing));
    
void Landing() {
    // TODO
}

 

为 iTween 指定特定的回调 : onupdate, oncomplete ...,布布扣,bubuko.com

为 iTween 指定特定的回调 : onupdate, oncomplete ...

标签:des   style   blog   http   color   for   

原文地址:http://www.cnblogs.com/yili16438/p/3842431.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!