簡體   English   中英

為什么onupdate無法在iTween上運行?

[英]Why does not onupdate run on iTween?

我正在實施紙牌配對游戲。

該事件將在首次部署卡后發送。

public void cardFlipStateUpdate()
{
    foreach (Card card in cardAllInformation[current_pageNumber])
    {
        GameObject card_gameObj = cardAllGameObject[current_pageNumber][card.cardIndex] as GameObject;

        int c_idx = card.cardIndex;
        int c_uidx = card.cardUniqueIndex;

        float delay_s = c_idx * 0.15f;
        float delay_r = 2.5f + c_idx * 0.15f;

        TouchEventManager.Instance.dispatch(c_idx, c_uidx, card_gameObj, card, true, "none", delay_s);
        TouchEventManager.Instance.dispatch(c_idx, c_uidx, card_gameObj, card, true, "cardSelectionCriteria", delay_r);
    }
}

public void onTuchHandler(object obj, EventArgs e)
{
    TouchEventTypes t_evt = e as TouchEventTypes;

    WordReviewUtil.cardFlipAnimation(t_evt.card_idx, t_evt.card_selectNum, t_evt.go, t_evt.card, t_evt.init, t_evt.complete, t_evt.delay);
}

這是接收上述事件的代碼。

   public static void cardFlipAnimation(int card_idx, int card_selectNum, GameObject gobj, Card card, bool init = false, string complete = "cardDifferentiate", float delay = 0f)
    {
        Hashtable data = new Hashtable();
    //    Debug.Log("cardFlipAnimation Receive Param >> " + card_idx + " / " + card_selectNum + " / " + gobj + " / ");
    //    Debug.Log("cardFlipAnimation Receive Param >> " + card + " / " + init + " / " + complete + " / " + delay);
    //    Debug.Log("============================================================================================");
        data.Add("gobj", gobj);
        data.Add("card", card);

        Hashtable run_hash = new Hashtable();
        run_hash.Add("y", 0.5);
        run_hash.Add("time", 0.7);
        run_hash.Add("delay", delay);
        run_hash.Add("easetype", iTween.EaseType.easeInOutCubic);
        run_hash.Add("onupdate", "test");
        run_hash.Add("onupdatetarget", gobj);
        run_hash.Add("onupdateparams", data);
        run_hash.Add("oncomplete", complete);
        run_hash.Add("oncompletetarget", gobj);

        //Debug.Log("run_hash >> " + run_hash);

        iTween.RotateBy(gobj, run_hash);
    }

我創建了一個臨時函數來檢查上面的代碼是否工作正常。 ((“ onupdate”,“ test”);)

public void test()
{
   Debug.Log("hello Moto~~");
}

但是日志無法驗證。

我找不到原因。

你寫錯什么了? 以及如何解決呢?

您的評論很有價值。 請幫我。

我相信您是在假設iTween使用標准哈希表的情況下創建哈希表的,但是它對我卻沒有用。 嘗試使用以下方法調用RotateBy:

iTween.RotateBy( gobj, iTween.Hash(
     "y", 0.5,
     "time", 0.7,
     "delay", delay,
     "easetype", iTween.EaseType.easeInOutCubic,
     "onupdate", "test",
     "onupdatetarget", gobj,
     "onupdateparams", data,
     "oncomplete", complete,
     "oncompletetarget", gobj
));

編輯:代碼中的方法Test沒有參數,而在這里您想將data作為參數傳遞:這將破壞它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM