Update: It seems it's the Nexus One. http://androidandme.com/2010/03/news/is-multitouch-broken-on-the-nexus-one/
Having said that, there appears to be a bug in the native mojo code anyway. In mojo.androidgl.java lines 71-72 (in the onTouchEvent method), you should be reading X and Y from the pointer ID, like this:
input.touchX[pid2]=event.getX(pid2);
input.touchY[pid2]=event.getY(pid2);
I guess I'm buying a new phone... :(
------------------------------------------------------
Try out this code and move your fingers around. See the problem? TouchX and TouchY seem to get confused about which event to take the value from as the X and Y values cross over.
I'm trying to use two virtual sticks (see my code in the Monkey Code forum) but they're messing each other up.
Testing on a Nexus One running Gingerbread (2.3.3). It appears my phone and/or OS version only supports two touches.
strict
import mojo
function Main:int()
new MyApp
return 0
end
class MyApp extends App
method OnCreate:int()
SetUpdateRate(120)
return 0
end
method OnUpdate:int()
return 0
end
method OnRender:int()
Cls(0,0,0)
local dy:int = 30
for local i:int = 0 to 31
if TouchDown(i) then
if i mod 2 = 0 then
SetColor(255,0,0)
else
SetColor(0,0,255)
end
DrawCircle(TouchX(i),TouchY(i),50)
SetColor(255,255,255)
DrawText(""+i, 10, dy)
DrawText(""+int(TouchX(i)), 40, dy)
DrawText(""+int(TouchY(i)), 80, dy)
dy+=20
end
end
DrawText("idx",10,10)
DrawText("x",40,10)
DrawText("y",80,10)
return 0
end
end
|