我想创建一个Multitouch游戏手柄控制处理和使用它来控制远程Arduino机器人。 我想在Processing上制作GUI并为Android编译它。游戏手柄控制处理+ Android来控制Arduino机器人
这里是GUI游戏手柄进行处理我已创建至今:
float easing = 0.09;
// start position
int posX = 50;
int posY = 200;
// target position
int targetX = 50;
int targetY = 200;
boolean dragging = false;
void setup()
{
size(500,250);
smooth();
}
void draw()
{
background(255);
if (!dragging)
{
// calculate the difference in position, apply easing and add to vx/vy
float vx = (targetX - (posX)) * easing;
float vy = (targetY - (posY)) * easing;
// Add the velocity to the current position: make it move!
posX += vx;
posY += vy;
}
if(mousePressed)
{
dragging = true;
posX = mouseX;
posY = mouseY;
}
else
{
dragging = false;
}
DrawGamepad();
DrawButtons();
}
void DrawGamepad()
{
//fill(0,155,155);
//rect(0, 150, 100, 100, 15);
ellipseMode(RADIUS); // Set ellipseMode to RADIUS
fill(0,155,155); // Set fill to blue
ellipse(50, 200, 50, 50); // Draw white ellipse using RADIUS mode
ellipseMode(CENTER); // Set ellipseMode to CENTER
fill(255); // Set fill to white//
ellipse(posX, posY, 35, 35); // Draw gray ellipse using CENTER mode
}
void DrawButtons()
{
fill(0,155,155); // Set fill to blue
ellipse(425, 225, 35, 35);
ellipse(475, 225, 35, 35);
fill(255,0,0); // Set fill to blue
ellipse(425, 175, 35, 35);
ellipse(475, 175, 35, 35);
}
我已经意识到,可能是代码将不支持Android上的多点触摸事件,所以我想出了这个链接
上找到另一个代码Can Processing handle multi-touch?
所以这个项目的目的是创造去多点触控手柄用来控制我的Arduino机器人。游戏手柄应检测按下哪个按键以及操纵杆的方向。
任何帮助表示赞赏。
到底是什么问题?为什么不能使用http://stackoverflow.com/questions/17166522/can-processing-handle-multi-touch上的代码? –
关键是我现在有两个代码。一个处理多玩偶事件,另一个处理游戏手柄控制。 我想将所有代码加入到一起,并在我的Android设备上运行它。我希望功能游戏手柄完成并与多点触控代码结合使用,但我无法使其工作。我将不胜感激任何帮助。最好的问候 – Iker