From 68edb7645cbdc85b2398cdbb3a49804bcdada979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kayyissa=20HA=C3=8FSSOUS?= Date: Tue, 4 Apr 2023 10:26:04 +0200 Subject: [PATCH] ajout listener --- .../com/example/mastermind/game/GameView.java | 1 + .../mastermind/game/TouchListener.java | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 app/src/main/java/com/example/mastermind/game/TouchListener.java diff --git a/app/src/main/java/com/example/mastermind/game/GameView.java b/app/src/main/java/com/example/mastermind/game/GameView.java index 491f160..2e14dff 100644 --- a/app/src/main/java/com/example/mastermind/game/GameView.java +++ b/app/src/main/java/com/example/mastermind/game/GameView.java @@ -23,6 +23,7 @@ public class GameView extends View { super(context); this.saisie=saisie; this.grille=grille; + this.setOnTouchListener(new TouchListener()); //on initialise les collections de pions initpions(); this.circle = new Paint(); diff --git a/app/src/main/java/com/example/mastermind/game/TouchListener.java b/app/src/main/java/com/example/mastermind/game/TouchListener.java new file mode 100644 index 0000000..5d9f135 --- /dev/null +++ b/app/src/main/java/com/example/mastermind/game/TouchListener.java @@ -0,0 +1,22 @@ +package com.example.mastermind.game; + +import android.view.MotionEvent; +import android.view.View; + +public class TouchListener implements View.OnTouchListener{ + + public TouchListener(){} + + @Override + public boolean onTouch(View v, MotionEvent event) { + int action = event.getActionMasked(); + Float x = event.getX(); + Float y = event.getY(); + + if (action==MotionEvent.ACTION_UP) + { + + } + return true; + } +}