I have a method which make move on click
public void processMove(int fromX, int fromY, int toX, int toY) {
...
if (moveCorrect()) {
makeMove(fromX, fromY, toX, toY);
}
...
}
This method called from handler of mouse clicks, added to the certain JPanel. This logic works fine until I found out that pawns can be transformed if they reaches last line. So I should show overlay in which user will choose piece to which pawn will be transformed. So I call PawnTransformOverlay.
if (//if pawn reaches last line) {
PawnTransfromOverlay.showOverlay();
}
I actually would like to stop the program until user will click, get clicked piece from overlay and transform pawn without leaving this if
statement. The only option I can come up with right now is to make handler for PawnTransformOverlay and call some function, like transformPawn()
from this handler on click. But then I will have to copy these fromX, fromY, toX, toY
to use them from transformPawn()
. It seems to be better way I don't know about.
Is it possible, or there is some other ways to do it better? Every ideas and tips will be really helpful!!!
To better understanding what I'm trying to ask: https://github.com/Yonshoku/Chess2
And link to the class where I can't figure out right way to do: https://github.com/Yonshoku/Chess2/blob/master/src/chessgui/Game.java
Aucun commentaire:
Enregistrer un commentaire