Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Juego extends SurfaceView implements View.OnTouchListener{
- private Paint paint;
- int radio = 100, x = 100, y = 100;
- public Juego(Context context, AttributeSet attrs) {
- super(context, attrs);
- this.setOnTouchListener(this);
- setFocusable(true);
- paint = new Paint();
- }
- public void onDraw(Canvas canvas) {
- paint.setColor(Color.WHITE);
- canvas.drawRect(0, 0, getWidth(), getHeight(), paint);
- paint.setColor(Color.BLACK);
- canvas.drawCircle(x, y, radio, paint);
- invalidate();
- }
- @Override
- public boolean onTouch(View view,MotionEvent motionEvent){
- x = (int)motionEvent.getX();
- y = (int)motionEvent.getY();
- invalidate();
- return true;
- }
- }
Add Comment
Please, Sign In to add comment