use of net.schattenkind.androidLove.LoveVM in project love-android by hagish.
the class LuanPhone method onTouch.
// / calls love.phone.touch(action,{id1,x1,y1,id2,x2,y2,...})
// / for action see also love.phone.MOTION_EVENT_ACTION_TYPE
// / you can define this callback similar to love.mousepressed to get detailed touch info
// / only if love.phone.enableTouchEvents() has been called
// / see http://developer.android.com/reference/android/view/MotionEvent.html for details about multitouch handling
public void onTouch(MotionEvent event) {
if (!mbEnableTouchEvents)
return;
// http://stackoverflow.com/questions/362424/accessing-constructor-of-an-anonymous-class
vm.FireEvent(new LoveVM.cLoveEvent() {
MotionEvent event;
public LoveVM.cLoveEvent MyInit(MotionEvent event) {
this.event = event;
return this;
}
public void Execute(LoveVM vm) {
if (!vm.isInitDone())
return;
try {
LuaTable t = new LuaTable();
for (int i = 0; i < event.getPointerCount(); ++i) {
t.set(1 + i * 3 + 0, LuaValue.valueOf(event.getPointerId(i)));
t.set(1 + i * 3 + 1, LuaValue.valueOf(event.getX(i)));
t.set(1 + i * 3 + 2, LuaValue.valueOf(event.getY(i)));
}
vm.get_G().get("love").get("phone").get("touch").call(LuaValue.valueOf(event.getAction()), t);
} catch (LuaError e) {
vm.handleLuaError(e);
}
}
}.MyInit(event));
}
Aggregations