本文整理汇总了Java中com.jme3.input.event.TouchEvent类的典型用法代码示例。如果您正苦于以下问题:Java TouchEvent类的具体用法?Java TouchEvent怎么用?Java TouchEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TouchEvent类属于com.jme3.input.event包,在下文中一共展示了TouchEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:InputManager.java
示例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;
}
}
}
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:24,代码来源:BaseScreen.java
示例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);
}
}
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:19,代码来源:BaseScreen.java
示例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);
}
}
}
}
}
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:22,代码来源:BaseScreen.java
示例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());
}
}
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:18,代码来源:BaseScreen.java
示例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;
}
}
}
开发者ID:neph1,项目名称:jme-cardboard,代码行数:23,代码来源:CardboardHarness.java
示例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;
}
}
}
开发者ID:meltzow,项目名称:tonegodgui,代码行数:23,代码来源:Screen.java
示例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);
}
}
}
开发者ID:meltzow,项目名称:tonegodgui,代码行数:21,代码来源:Screen.java
示例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);
}
}
}
}
}
开发者ID:meltzow,项目名称:tonegodgui,代码行数:19,代码来源:Screen.java
示例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;
}
开发者ID:meltzow,项目名称:tonegodgui,代码行数:24,代码来源:SubScreen.java
示例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;
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:27,代码来源:GdxInput.java
示例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;
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:21,代码来源:GdxInput.java
示例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;
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:22,代码来源:GdxInput.java
示例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;
}
}
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:25,代码来源:AndroidHarness.java
示例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;
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:21,代码来源:AndroidInput.java
示例16: onKeyUp
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
@Override
public boolean onKeyUp (int keyCode, KeyEvent event)
{
TouchEvent evt;
evt = getNextFreeTouchEvent();
evt.set(TouchEvent.Type.KEY_UP);
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;
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:20,代码来源:AndroidInput.java
示例17: onTouchEvent
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
/**
* Callback from RawInputListener. Do not use.
*/
@Override
public void onTouchEvent(TouchEvent evt) {
if (!eventsPermitted) {
throw new UnsupportedOperationException("TouchInput has raised an event at an illegal time.");
}
inputQueue.add(evt);
}
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:InputManager.java
示例18: onFling
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
@Override
public void onFling(TouchEvent evt) {
if (flingEnabled && (evt.getDeltaY() > 0.2f || evt.getDeltaY() < -0.2f)) {
if (!screen.getAnimManager().hasGameTimer(flingTimer)) {
flingTimer.reset(false);
flingDir = (evt.getDeltaY() < 0) ? true : false;
flingSpeed = FastMath.abs(evt.getDeltaY());
screen.getAnimManager().addGameTimer(flingTimer);
}
}
}
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:12,代码来源:ScrollPanel.java
示例19: onTouchDown
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
@Override
public void onTouchDown(TouchEvent evt) {
if (screen.getAnimManager().hasGameTimer(flingTimer)) {
flingTimer.endGameTimer();
screen.getAnimManager().removeGameTimer(flingTimer);
}
if (flingEnabled) {
touchStartY = getScrollableAreaVerticalPosition();
touchOffsetY = evt.getY() - touchStartY;
}
}
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:12,代码来源:ScrollPanel.java
示例20: onTouchMove
import com.jme3.input.event.TouchEvent; //导入依赖的package包/类
@Override
public void onTouchMove(TouchEvent evt) {
if (flingEnabled) {
float nextY = evt.getY() - touchOffsetY;
if (nextY <= getScrollableAreaHeight() && nextY >= innerBounds.getHeight()) {
scrollYTo(nextY);
setVThumbPositionToScrollArea();
touchEndY = getScrollableAreaVerticalPosition();
}
}
}
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:12,代码来源:ScrollPanel.java
注:本文中的com.jme3.input.event.TouchEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论