Search

Enable drag in sketchware

Instagram Follow on Instagram


Follow This Step to Enable Drag in sketchware

01.Create a NewProject on Sketchware
02.Create a MoreBlock (Enable View:View)



03. Now put a Source Directly Block to following MoreBlock and Past this Source codes to it.





Code

_view.setOnTouchListener(new OnTouchListener() { PointF DownPT = new PointF();
PointF StartPT = new PointF();
@Override public boolean onTouch(View v, MotionEvent event) { int eid = event.getAction();
switch (eid) { case MotionEvent.ACTION_MOVE:PointF mv = new PointF(event.getX() - DownPT.x, event.getY() - DownPT.y); _view.setX((int)(StartPT.x+mv.x));
_view.setY((int)(StartPT.y+mv.y));
StartPT = new PointF(_view.getX(), _view.getY()); break;
case MotionEvent.ACTION_DOWN : DownPT.x = event.getX();
DownPT.y = event.getY(); StartPT = new PointF(_view.getX(), _view.getY()); break;
case MotionEvent.ACTION_UP : break; default : break;
} return true; } });


04.Now Place a you created MorBlock.



Post a Comment

0 Comments