Back to project page 101AndroidApps.
The source code is released under:
Licenced under the Creative Commons Attribution 4.0 licence. For full text see http://creativecommons.org/licenses/by/4.0/
If you think the Android project 101AndroidApps listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.hulzenga.ioi.android.app_004; //w w w . j ava 2 s . co m import android.content.Context; import android.opengl.GLSurfaceView; import android.util.AttributeSet; import android.view.MotionEvent; import com.hulzenga.ioi.android.util.open_gl.engine.SceneGraph; class BouncyBall3dGLSurfaceView extends GLSurfaceView { private BouncyBall3dRenderer mRenderer; private float mPreviousX; private float mPreviousY; public BouncyBall3dGLSurfaceView(Context context) { this(context, null); } public BouncyBall3dGLSurfaceView(Context context, AttributeSet attrs) { super(context, attrs); } public void setScene(SceneGraph sceneGraph) { mRenderer = new BouncyBall3dRenderer(getContext(), sceneGraph); setEGLContextClientVersion(2); setRenderer(mRenderer); } @Override public boolean onTouchEvent(MotionEvent e) { if (e != null) { float x = e.getX(); float y = e.getY(); switch (e.getAction()) { case MotionEvent.ACTION_MOVE: final float dx = x - mPreviousX; final float dy = y - mPreviousY; mRenderer.touchMove(dx, dy); } mPreviousX = x; mPreviousY = y; return true; } return super.onTouchEvent(e); } }