我目前正在使用带有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()方法的实现?
您仍然应该可以设置将逻辑添加到其顶部。例如,您将拥有单独的自定义光标ID列表,这些列表将基于TuioCursor事件进行更新。
这仅是一个示例,假设您要在ArrayList
的Integer
中添加您的自定义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);
}
}
这本身不是一个超级自身:您可能希望使自定义光标类不仅包含ID,而且还包含x,y或对TuioCursor
的引用,无论最终目标是什么。没有什么可以阻止您基于TUIO事件管理您自己的自定义光标数据列表。