首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么onupdate不能在iTween上运行?

为什么onupdate不能在iTween上运行?
EN

Stack Overflow用户
提问于 2017-11-14 18:17:57
回答 1查看 478关注 0票数 0

我正在实现一个卡片匹配游戏。

该事件将在卡片首次部署后发送。

代码语言:javascript
复制
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);
}

以下是接收上述事件的代码。

代码语言:javascript
复制
   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");)

代码语言:javascript
复制
public void test()
{
   Debug.Log("hello Moto~~");
}

但是日志无法验证。

我找不到原因。

你写错了什么?如何解决这个问题?

您的意见很有价值。请帮帮我。

EN

回答 1

Stack Overflow用户

发布于 2017-11-14 20:15:27

我相信你是在假设iTween使用标准哈希表的情况下创建哈希表,但这对我来说从来都不起作用。尝试使用以下代码调用RotateBy:

代码语言:javascript
复制
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作为参数传递:这会破坏它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47283094

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档