내 안드로이드 게임에 OpenGL을 사용하고 있습니다. 나는 x와 y 위치를 잡고 싶다. 나는 다른 튜토리얼을 따랐고 모든 것이 같은 결과로 이어졌다. 나는 그것으로부터 아무것도 얻을 수 없다. 이 방법은 심지어 내가 이상한 것을 발견하지도 않는다. 그래서, 여기에 내 GLSurfaceView 클래스android ontouchevent opengl
class OpenGLES10SurfaceView extends GLSurfaceView {
//private final float TOUCH_SCALE_FACTOR = 180.0f/320;
public OpenGLES10Renderer mRenderer;
//static private float mPreviousX;
//static private float mPreviousY;
private static float _x;
private static float _y;
public OpenGLES10SurfaceView(Context context){
super(context);
// set the mRenderer member
mRenderer = new OpenGLES10Renderer(context);
setRenderer(mRenderer);
// Render the view only when there is a change
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
@Override
public boolean onTouchEvent(MotionEvent e) {
// MotionEvent reports input details from the touch screen
// and other input controls. In this case, you are only
// interested in events where the touch position changed.
float x = e.getX();
float y = e.getY();
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
mRenderer.setX(x);
return true;
}
}
}
나는 당신이이 대단히 appriciated 될 것입니다 도움이 될 수 있다면 도대체 번째 그래서이 잘못이 무엇인지 찾을 수 없습니다입니다. 코드의 일부가 필요한 경우 그렇게 말하십시오.
보기에서 OnTouchListener를 설정하는 것을 잊지 않았습니까? – JoxTraex
활동에 contentview를 설정 한 부분을 포함시킬 수 있습니까? 또한 활동에서 onTouchEvent()를 추가하면보기를 소비하지 않는 경우 이벤트를 수신해야 문제를 디버그하는 데 도움이됩니다. – Aert