[英]How to implement andengine surfacegesturedetector adapter in gles2?
I want to implement swipe gestures in my game. 我想在游戏中实现滑动手势。 search on net but not accurate result found.
网上搜索,但未找到准确的结果。 Please anyone help me to implement surfacegesturedetectorAdapter in andengine gles2 .
请人帮我在andengine gles2实施surfacegesturedetectorAdapter。
The logcate say: 日志中说:
"Can't create handler inside thread that has not called Looper.prepare()" “无法在未调用Looper.prepare()的线程内创建处理程序”
I also tried onUiThread method but it isn't work. 我也尝试过onUiThread方法,但是它不起作用。 if anyone found solution please help..... THANS....in adv.
如果有人找到解决方案,请帮助。
Call below method inside onloadScene() : 在onloadScene()内部调用以下方法:
private void setupGestureDetaction(){
SurfaceGestureDetector surfaceGestureDetector = new SurfaceGestureDetector(1f) {
@Override
protected boolean onSwipeUp() {
System.out.println("onSwipeUp");
return true;
}
@Override
protected boolean onSwipeRight() {
System.out.println("onSwipeRight");
return true;
}
@Override
protected boolean onSwipeLeft() {
System.out.println("onSwipeLeft");
return true;
}
@Override
protected boolean onSwipeDown() {
System.out.println("onSwipeDown");
return true;
}
@Override
protected boolean onSingleTap() {
System.out.println("onSingleTap");
return true;
}
@Override
protected boolean onDoubleTap() {
System.out.println("onDoubleTap");
return true;
}
@Override
public boolean onManagedTouchEvent(TouchEvent pSceneTouchEvent) {
return super.onManagedTouchEvent(pSceneTouchEvent);
}
@Override
public boolean onSceneTouchEvent(Scene pScene,
TouchEvent pSceneTouchEvent) {
return super.onSceneTouchEvent(pScene, pSceneTouchEvent);
}
};
surfaceGestureDetector.setEnabled(true);
mScene.setOnSceneTouchListener(surfaceGestureDetector);
}
In above method you need to make your modifications as per your need. 在上述方法中,您需要根据需要进行修改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.