【问题标题】:How to change the addTuioCursor() implementation with processing?如何通过处理更改 addTuioCursor() 实现?
【发布时间】:2020-01-18 14:10:00
【问题描述】:

我目前正在使用带有 TUIO 库的处理语言开发一款小型多点触控游戏。
我想根据添加光标的屏幕的哪一半手动设置 CursorID,并且由于唯一一次调用该方法,它只打印一条消息,如下所示。

// called when a cursor is added to the scene
void addTuioCursor(TuioCursor tcur) {
  if (verbose) println("add cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+ ") " +tcur.getX()+" "+tcur.getY());
  //redraw();
}

我搜索了一下,但我找不到任何东西。有没有办法改变 addTuioCursor() 方法的实现?

【问题讨论】:

    标签: processing multi-touch tuio


    【解决方案1】:

    您应该仍然可以在其上设置添加您的逻辑。 例如,您将拥有基于 TuioCursor 事件更新的自定义光标 ID 的单独列表。

    这只是一个说明,假设您有一个 ArrayListInteger 来添加您的自定义 ID:

    // called when a cursor is added to the scene
    void addTuioCursor(TuioCursor tcur) {
      if (verbose) println("add cur "+tcur.getCursorID()+" ("+tcur.getSessionID()+ ") " +tcur.getX()+" "+tcur.getY());
      // if newly added cursor is on the left half of the screen
      if(tcur.getX() < width / 2){
        // set a custom ID
        int customID = (int)random(0,100);
        // add a custom ID
        //leftCursorsList.add(customID);
      }
    }
    

    This is intself 可能不是超级你自己:您可能希望自定义光标类不仅包含 ID,还可能包含 x、y 或对 TuioCursor 的引用,无论您的最终目标是什么。没有什么能阻止您根据 TUIO 事件管理自己的自定义光标数据列表。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-23
      • 2013-02-18
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 2018-03-22
      • 2020-03-16
      • 1970-01-01
      相关资源
      最近更新 更多