use of com.jme3.input.event.TouchEvent in project jmonkeyengine by jMonkeyEngine.
the class IosTouchHandler method actionMove.
public void actionMove(int pointerId, long time, float x, float y) {
float jmeX = iosInput.getJmeX(x);
float jmeY = iosInput.invertY(iosInput.getJmeY(y));
Vector2f lastPos = lastPositions.get(pointerId);
if (lastPos == null) {
lastPos = new Vector2f(jmeX, jmeY);
lastPositions.put(pointerId, lastPos);
}
float dX = jmeX - lastPos.x;
float dY = jmeY - lastPos.y;
if (dX != 0 || dY != 0) {
TouchEvent touch = iosInput.getFreeTouchEvent();
touch.set(TouchEvent.Type.MOVE, jmeX, jmeY, dX, dY);
touch.setPointerId(pointerId);
touch.setTime(time);
touch.setPressure(1.0f);
//touch.setPressure(event.getPressure(p));
lastPos.set(jmeX, jmeY);
processEvent(touch);
}
}
use of com.jme3.input.event.TouchEvent in project jmonkeyengine by jMonkeyEngine.
the class TouchEventPool method getNextFreeEvent.
/**
* Fetches a touch event from the reuse pool
*
* @return a usable TouchEvent
*/
public TouchEvent getNextFreeEvent() {
TouchEvent evt = null;
int curSize = eventPool.size();
while (curSize > 0) {
evt = (TouchEvent) eventPool.pop();
if (evt.isConsumed()) {
break;
} else {
eventPool.push(evt);
evt = null;
}
curSize--;
}
if (evt == null) {
logger.warning("eventPool full of unconsumed events");
evt = new TouchEvent();
}
return evt;
}
Aggregations