Guest User

Untitled

a guest
Feb 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public class Juego extends SurfaceView implements View.OnTouchListener{
  2.  
  3. private Paint paint;
  4. int radio = 100, x = 100, y = 100;
  5.  
  6. public Juego(Context context, AttributeSet attrs) {
  7. super(context, attrs);
  8. this.setOnTouchListener(this);
  9. setFocusable(true);
  10. paint = new Paint();
  11. }
  12.  
  13. public void onDraw(Canvas canvas) {
  14.  
  15. paint.setColor(Color.WHITE);
  16. canvas.drawRect(0, 0, getWidth(), getHeight(), paint);
  17.  
  18. paint.setColor(Color.BLACK);
  19. canvas.drawCircle(x, y, radio, paint);
  20.  
  21. invalidate();
  22. }
  23.  
  24. @Override
  25. public boolean onTouch(View view,MotionEvent motionEvent){
  26.  
  27. x = (int)motionEvent.getX();
  28. y = (int)motionEvent.getY();
  29.  
  30. invalidate();
  31. return true;
  32. }
  33. }
Add Comment
Please, Sign In to add comment