Ajout futur img bouton + bouton retour fonctionnel

This commit is contained in:
Claire G 2023-04-08 10:44:07 +02:00
parent 8b8ff56069
commit 38d267b8b2
6 changed files with 16 additions and 7 deletions

View File

@ -1,6 +1,8 @@
package com.example.mastermind.game;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
@ -22,6 +24,9 @@ public class GameView extends View {
private Bot theBot;
private Paint circle;
private boolean state;
private Bitmap cancelBtn;
private Bitmap backBtn;
private Bitmap validBtn;
public GameView(Context context,Saisie saisie,Grille grille, boolean bot) {
super(context);
this.saisie=saisie;
@ -85,6 +90,9 @@ public class GameView extends View {
//TODO: ajout des boutons
//Test de bouton valider
/*validBtn = BitmapFactory.decodeResource(getResources(), R.drawable.valid_button);
canvas.drawBitmap(validBtn, this.getWidth()/2+this.getWidth()/11-this.getWidth()/13, this.getHeight()/2+this.getHeight()/16+this.getWidth()/13, null);*/
this.circle.setColor(this.getResources().getColor(R.color.green));
canvas.drawCircle((this.getWidth()/2)+(getWidth()/11)*2,this.getHeight()-this.getHeight()/16, this.getWidth()/13, this.circle);
// bouton retour
@ -133,10 +141,10 @@ public class GameView extends View {
this.invalidate();
}
/*public void removeChoix() {
public void removePion() {
this.saisie.removeSelection(this.getResources().getColor(R.color.pionVide));
this.invalidate();
}*/
}
public void clearChoix() {
this.saisie.initSelection(this.getResources().getColor(R.color.pionVide));

View File

@ -47,12 +47,13 @@ public class Saisie {
}
/*public void removeSelection(Integer color) {
if(this.sizeSelection<=4) {
public void removeSelection(Integer pionVide) {
if(this.sizeSelection<=4 && this.sizeSelection>0) {
this.selection.removeLast();
this.selection.add(pionVide);
this.sizeSelection-=1;
this.selection.set(this.sizeSelection, this.choix.get(color));
}
}*/
}
public int getSizeSelection(){
return this.sizeSelection;

View File

@ -41,7 +41,7 @@ public class TouchListener implements View.OnTouchListener{
this.view.changeState();
i = 0;
} else if (v.getWidth()/2-v.getWidth()/13<x && x<v.getWidth()/2+v.getWidth()/13) { // retour
//this.view.removeChoix();
this.view.removePion();
} else if (v.getWidth()/2-(v.getWidth()/11)*2-v.getWidth()/13<x && x<v.getWidth()/2-(v.getWidth()/11)*2+v.getWidth()/13) { // annuler
this.view.clearChoix();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB