本文整理汇总了Java中com.jme3.input.event.TouchEvent类的典型用法代码示例。如果您正苦于以下问题:Java TouchEvent类的具体用法?Java TouchEvent怎么用?Java TouchEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TouchEvent类属于com.jme3.input.event包,在下文中一共展示了TouchEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onTouchEventQueued
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
/**
* Dispatches touch events to touch listeners
* @param evt The touch event to be dispatched to all onTouch listeners
*/
public void onTouchEventQueued(TouchEvent evt) {
ArrayList<Mapping> maps = bindings.get(TouchTrigger.touchHash(evt.getKeyCode()));
if (maps == null) {
return;
}
int size = maps.size();
for (int i = size - 1; i >= 0; i--) {
Mapping mapping = maps.get(i);
ArrayList<InputListener> listeners = mapping.listeners;
int listenerSize = listeners.size();
for (int j = listenerSize - 1; j >= 0; j--) {
InputListener listener = listeners.get(j);
if (listener instanceof TouchListener) {
((TouchListener) listener).onTouch(mapping.name, evt, frameTPF);
}
}
}
}
示例2: onTouchEvent
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
@Override
public void onTouchEvent(TouchEvent evt) {
setTouchXY(evt.getX(), evt.getY());
// evt.set(evt.getType(),touchXY.x,touchXY.y,evt.getDeltaX()*inputScale,evt.getDeltaY()*inputScale);
if (useMultiTouch) {
switch (evt.getType()) {
case DOWN:
androidTouchDownEvent(evt);
break;
case MOVE:
androidTouchMoveEvent(evt);
break;
case UP:
androidTouchUpEvent(evt);
break;
case FLING:
androidFlingEvent(evt);
default:
break;
}
}
}
示例3: s3dOnTouchDownEvent
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void s3dOnTouchDownEvent(TouchEvent evt) {
float x = ToolKit.isAndroid() ? touchXY.x : mouseXY.x;
float y = ToolKit.isAndroid() ? touchXY.y : mouseXY.y;
Node target = getEventNode(x, y);
if (target != null) {
MouseUIButtonEvent<NodeEventTarget> mevt = new MouseUIButtonEvent<NodeEventTarget>(
new MouseButtonEvent(0, true, (int) x, (int) y), new NodeEventTarget(this, target),
keyboardModifiers);
if (target instanceof MouseButtonListener) {
((MouseButtonListener<NodeEventTarget>) target).onMouseButton(mevt);
}
if (target instanceof TouchListener) {
((TouchListener) target).onTouchDown(evt);
}
eventNodes.put(evt.getPointerId(), target);
}
}
示例4: s3dOnTouchMoveEvent
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
private void s3dOnTouchMoveEvent(TouchEvent evt) {
float x = ToolKit.isAndroid() ? touchXY.x : mouseXY.x;
float y = ToolKit.isAndroid() ? touchXY.y : mouseXY.y;
for (Integer key : eventNodes.keySet()) {
if (key == evt.getPointerId()) {
Node target = eventNodes.get(key);
if (target != null) {
if (target instanceof MouseMovementListener) {
((MouseMovementListener<NodeEventTarget>) target)
.onMouseMove(new MouseUIMotionEvent<NodeEventTarget>(
new MouseMotionEvent((int) x, (int) y, (int) evt.getDeltaX(),
(int) evt.getDeltaY(), 0, 0),
new NodeEventTarget(this, target), keyboardModifiers));
}
if (target instanceof TouchListener) {
((TouchListener) target).onTouchMove(evt);
}
}
}
}
}
示例5: s3dOnTouchUpEvent
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void s3dOnTouchUpEvent(TouchEvent evt) {
float x = ToolKit.isAndroid() ? touchXY.x : mouseXY.x;
float y = ToolKit.isAndroid() ? touchXY.y : mouseXY.y;
Node target = eventNodes.get(evt.getPointerId());
if (target != null) {
MouseUIButtonEvent<NodeEventTarget> mevt = new MouseUIButtonEvent<NodeEventTarget>(0, true, (int) x,
(int) y, 0, 0, getClickCount(), keyboardModifiers, new NodeEventTarget(this, target));
if (target instanceof MouseButtonListener) {
((MouseButtonListener<NodeEventTarget>) target).onMouseButton(mevt);
}
if (target instanceof TouchListener) {
((TouchListener) target).onTouchUp(evt);
}
eventNodes.remove(evt.getPointerId());
}
}
示例6: onTouch
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
/**
* Gets called by the InputManager on all touch/drag/scale events
*/
@Override
public void onTouch(String name, TouchEvent evt, float tpf) {
if (name.equals(ESCAPE_EVENT)) {
switch (evt.getType()) {
case KEY_UP:
runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog dialog = new AlertDialog.Builder(CardboardHarness.this) // .setIcon(R.drawable.alert_dialog_icon)
.setTitle(exitDialogTitle).setPositiveButton("Yes", CardboardHarness.this).setNegativeButton("No", CardboardHarness.this).setMessage(exitDialogMessage).create();
dialog.show();
}
});
break;
default:
break;
}
}
}
示例7: onTouchEvent
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
@Override
public void onTouchEvent(TouchEvent evt) {
setTouchXY(evt.getX(),evt.getY());
// evt.set(evt.getType(),touchXY.x,touchXY.y,evt.getDeltaX()*inputScale,evt.getDeltaY()*inputScale);
if (useMultiTouch) {
switch (evt.getType()) {
case DOWN:
androidTouchDownEvent(evt);
break;
case MOVE:
androidTouchMoveEvent(evt);
break;
case UP:
androidTouchUpEvent(evt);
break;
case FLING:
androidFlingEvent(evt);
break;
}
}
}
示例8: androidFlingEvent
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
/**
* This scales the current event values of deltaX and deltaY to a value between 0.0f and 1.0f
* @param evt
*/
private void androidFlingEvent(TouchEvent evt) {
setTouchXY(evt.getX(),evt.getY());
float flingX = 1f/8000f*evt.getDeltaX();
float flingY = 1f/8000f*evt.getDeltaY();
evt.set(evt.getType(), touchXY.x, touchXY.y, flingX, flingY);
Element contact = getContactElement(touchXY.x, touchXY.y, EventCheckType.Fling);
Vector2f offset = tempElementOffset.clone();
Element target = getEventElement(touchXY.x, touchXY.y, EventCheckType.Fling);
if (target != null) {
if (target instanceof FlingListener) {
((FlingListener)target).onFling(evt);
}
}
}
示例9: s3dOnTouchMoveEvent
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
private void s3dOnTouchMoveEvent(TouchEvent evt) {
float x = Screen.isAndroid() ? touchXY.x : mouseXY.x;
float y = Screen.isAndroid() ? touchXY.y : mouseXY.y;
for (Integer key : eventNodes.keySet()) {
if (key == evt.getPointerId()) {
Node target = eventNodes.get(key);
if (target != null) {
if (target instanceof MouseMovementListener) {
MouseMotionEvent mbEvt = new MouseMotionEvent((int)x,(int)y,(int)evt.getDeltaX(),(int)evt.getDeltaY(),0,0);
((MouseMovementListener)target).onMouseMove(mbEvt);
}
if (target instanceof TouchListener) {
((TouchListener)target).onTouchMove(evt);
}
}
}
}
}
示例10: androidTouchUpEvent
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
private void androidTouchUpEvent(TouchEvent evt) {
Element target = eventElements.get(evt.getPointerId());
if (target != null) {
if (target instanceof MouseButtonListener) {
MouseButtonEvent mbEvt = new MouseButtonEvent(0, true, (int)evt.getX(), (int)evt.getY());
((MouseButtonListener)target).onMouseLeftReleased(mbEvt);
}
if (target instanceof TouchListener) {
((TouchListener)target).onTouchUp(evt);
}
if (!(target.getAbsoluteParent() instanceof AutoHide)) {
handleAndroidMenuState(target);
}
if (target != null)
evt.setConsumed();
eventElements.remove(evt.getPointerId());
contactElements.remove(evt.getPointerId());
elementOffsets.remove(evt.getPointerId());
eventElementResizeDirections.remove(evt.getPointerId());
} else
handleMenuState();
mousePressed = false;
}
示例11: touchDown
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
//mouseMoved2(screenX, screenY);
TouchEvent event = getNextFreeTouchEvent();
//event.set(TouchEvent.Type.MOVE, screenX, Gdx.graphics.getHeight() - screenY, 0, 0);
//event.setPointerId(0);
//event.setTime(System.nanoTime());
//processEvent(event);
//event = getNextFreeTouchEvent();
event.set(TouchEvent.Type.DOWN, screenX, Gdx.graphics.getHeight() - screenY, 0, 0);
event.setPointerId(0);
event.setTime(System.nanoTime());
processEvent(event);
Vector2f lastPos = lastPositions.get(pointer);
if (lastPos == null)
{
lastPos = new Vector2f(screenX, Gdx.graphics.getHeight() - screenY);
lastPositions.put(pointer, lastPos);
}
lastPos.set(screenX, Gdx.graphics.getHeight() - screenY);
System.err.println("touchDown x = " + screenX + " y = " + screenY);
return false;
}
示例12: touchDragged
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
if (screenX < 0 || screenY < 0) {
return false;
}
Vector2f lastPos = lastPositions.get(pointer);
if (lastPos == null)
{
lastPos = new Vector2f(screenX, Gdx.graphics.getHeight() - screenY);
lastPositions.put(pointer, lastPos);
}
TouchEvent event = getNextFreeTouchEvent();
event.set(TouchEvent.Type.MOVE, screenX, Gdx.graphics.getHeight() - screenY, screenX - lastPos.x, Gdx.graphics.getHeight() - screenY - lastPos.y);
event.setPointerId(pointer);
event.setTime(System.nanoTime());
processEvent(event);
System.err.println("touchDragged x = " + screenX + " y = " + screenY);
lastPos.set(screenX, Gdx.graphics.getHeight() - screenY);
return false;
}
示例13: mouseMoved2
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
public boolean mouseMoved2(int screenX, int screenY) {
if (screenX < 0 || screenY < 0) {
return false;
}
Vector2f lastPos = lastPositions.get(0);
if (lastPos == null)
{
lastPos = new Vector2f(screenX, Gdx.graphics.getHeight() - screenY);
lastPositions.put(0, lastPos);
}
TouchEvent event = getNextFreeTouchEvent();
event.set(TouchEvent.Type.MOVE, screenX, Gdx.graphics.getHeight() - screenY, screenX - lastPos.x, Gdx.graphics.getHeight() - screenY - lastPos.y);
event.setPointerId(0);
event.setTime(System.nanoTime());
processEvent(event);
// System.err.println("mouseMoved x = " + screenX + " y = " + screenY);
lastPos.set(screenX, Gdx.graphics.getHeight() - screenY);
return false;
}
示例14: onTouch
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
/**
* Gets called by the InputManager on all touch/drag/scale events
*/
@Override
public void onTouch(String name, TouchEvent evt, float tpf) {
if (name.equals(ESCAPE_EVENT)) {
switch (evt.getType()) {
case KEY_UP:
this.runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog dialog = new AlertDialog.Builder(AndroidHarness.this) // .setIcon(R.drawable.alert_dialog_icon)
.setTitle(exitDialogTitle).setPositiveButton("Yes", AndroidHarness.this).setNegativeButton("No", AndroidHarness.this).setMessage(exitDialogMessage).create();
dialog.show();
}
});
break;
default:
break;
}
}
}
示例15: onKeyDown
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
@Override
public boolean onKeyDown (int keyCode, KeyEvent event)
{
TouchEvent evt;
evt = getNextFreeTouchEvent();
evt.set(TouchEvent.Type.KEY_DOWN);
evt.setKeyCode(keyCode);
evt.setCharacters(event.getCharacters());
evt.setTime(event.getEventTime());
// Send the event
processEvent(evt);
// Handle all keys ourself except Volume Up/Down
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) || (keyCode == KeyEvent.KEYCODE_MENU) || (keyCode == KeyEvent.KEYCODE_BACK))
return false;
else
return true;
}