Back to project page Verlet.
The source code is released under:
Copyright 2013 Devicement http://devicement.com/ Copyright 2013 Sub Protocol and other contributors http://subprotocol.com/ Permission is hereby granted, free of charge, to any person obtaining a co...
If you think the Android project Verlet 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 org.verletandroid.Handlers; //from w w w. jav a2 s . c o m import android.util.Log; import android.view.MotionEvent; import android.view.View; import org.verletandroid.VerletCore.Verlet; /** * Created with IntelliJ IDEA. * User: George * Date: 01.05.13 * Time: 13:19 * To change this template use File | Settings | File Templates. */ public class InputVerletHandler implements View.OnTouchListener { private Verlet verlet; private final float scaleX; private final float scaleY; public InputVerletHandler(Verlet sim, float scaleX, float scaleY) { this.verlet = sim; this.scaleX = scaleX; this.scaleY = scaleY; } @Override public boolean onTouch(View view, MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { verlet.onTouchDown(event.getX()*scaleX, event.getY()*scaleY, 0); Log.v("Touch", String.format("ACTION_DOWN x:%.2f y:%.2f", event.getX(), event.getY())); } else if(event.getAction() == MotionEvent.ACTION_MOVE) { verlet.onTouchMove(event.getX()*scaleX, event.getY()*scaleY, 0); Log.v("Touch","ACTION_MOVE"); } else if(event.getAction() == MotionEvent.ACTION_UP) { verlet.onTouchUp(event.getX()*scaleX, event.getY()*scaleY, 0); Log.v("Touch","ACTION_UP"); } return true; } }