Ajout futur img bouton + bouton retour fonctionnel
This commit is contained in:
parent
8b8ff56069
commit
38d267b8b2
@ -1,6 +1,8 @@
|
|||||||
package com.example.mastermind.game;
|
package com.example.mastermind.game;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
@ -22,6 +24,9 @@ public class GameView extends View {
|
|||||||
private Bot theBot;
|
private Bot theBot;
|
||||||
private Paint circle;
|
private Paint circle;
|
||||||
private boolean state;
|
private boolean state;
|
||||||
|
private Bitmap cancelBtn;
|
||||||
|
private Bitmap backBtn;
|
||||||
|
private Bitmap validBtn;
|
||||||
public GameView(Context context,Saisie saisie,Grille grille, boolean bot) {
|
public GameView(Context context,Saisie saisie,Grille grille, boolean bot) {
|
||||||
super(context);
|
super(context);
|
||||||
this.saisie=saisie;
|
this.saisie=saisie;
|
||||||
@ -85,6 +90,9 @@ public class GameView extends View {
|
|||||||
|
|
||||||
//TODO: ajout des boutons
|
//TODO: ajout des boutons
|
||||||
//Test de bouton valider
|
//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));
|
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);
|
canvas.drawCircle((this.getWidth()/2)+(getWidth()/11)*2,this.getHeight()-this.getHeight()/16, this.getWidth()/13, this.circle);
|
||||||
// bouton retour
|
// bouton retour
|
||||||
@ -133,10 +141,10 @@ public class GameView extends View {
|
|||||||
this.invalidate();
|
this.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public void removeChoix() {
|
public void removePion() {
|
||||||
this.saisie.removeSelection(this.getResources().getColor(R.color.pionVide));
|
this.saisie.removeSelection(this.getResources().getColor(R.color.pionVide));
|
||||||
this.invalidate();
|
this.invalidate();
|
||||||
}*/
|
}
|
||||||
|
|
||||||
public void clearChoix() {
|
public void clearChoix() {
|
||||||
this.saisie.initSelection(this.getResources().getColor(R.color.pionVide));
|
this.saisie.initSelection(this.getResources().getColor(R.color.pionVide));
|
||||||
|
@ -47,12 +47,13 @@ public class Saisie {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public void removeSelection(Integer color) {
|
public void removeSelection(Integer pionVide) {
|
||||||
if(this.sizeSelection<=4) {
|
if(this.sizeSelection<=4 && this.sizeSelection>0) {
|
||||||
|
this.selection.removeLast();
|
||||||
|
this.selection.add(pionVide);
|
||||||
this.sizeSelection-=1;
|
this.sizeSelection-=1;
|
||||||
this.selection.set(this.sizeSelection, this.choix.get(color));
|
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
public int getSizeSelection(){
|
public int getSizeSelection(){
|
||||||
return this.sizeSelection;
|
return this.sizeSelection;
|
||||||
|
@ -41,7 +41,7 @@ public class TouchListener implements View.OnTouchListener{
|
|||||||
this.view.changeState();
|
this.view.changeState();
|
||||||
i = 0;
|
i = 0;
|
||||||
} else if (v.getWidth()/2-v.getWidth()/13<x && x<v.getWidth()/2+v.getWidth()/13) { // retour
|
} 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
|
} 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();
|
this.view.clearChoix();
|
||||||
}
|
}
|
||||||
|
BIN
app/src/main/res/drawable/back_button.png
Normal file
BIN
app/src/main/res/drawable/back_button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
BIN
app/src/main/res/drawable/cancel_button.png
Normal file
BIN
app/src/main/res/drawable/cancel_button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
app/src/main/res/drawable/valid_button.png
Normal file
BIN
app/src/main/res/drawable/valid_button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
Loading…
Reference in New Issue
Block a user