Disable remove animation when dragging
This commit is contained in:
parent
07c8d0b835
commit
86a2ee195b
|
@ -165,7 +165,7 @@ public abstract class APiece {
|
|||
chessboard.removePiece(x, y);
|
||||
APiece piece = chessboard.getPiece(pos.x, pos.y);
|
||||
if(piece != null) {
|
||||
piece.remove();
|
||||
piece.remove(animate);
|
||||
}
|
||||
x = pos.x;
|
||||
y = pos.y;
|
||||
|
@ -348,8 +348,9 @@ public abstract class APiece {
|
|||
}, 5, 5);
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
public void remove(boolean animate) {
|
||||
chessboard.removePiece(x, y);
|
||||
if(!animate) return;
|
||||
Timer timer = new Timer();
|
||||
scale = .99;
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
|
@ -96,11 +95,11 @@ public class ChessboardMouseAdapter extends MouseAdapter {
|
|||
if(piece != null) {
|
||||
if(piece.getPossibleMoves()[pos.y][pos.x]) {
|
||||
piece.move(pos, false);
|
||||
c.showPossibleMoves(null);
|
||||
if(c.getActivePlayer().inCheck()) System.out.println("Inactive player in check!");
|
||||
c.changeActivePlayer();
|
||||
if(c.getActivePlayer().inCheck()) System.out.println("Active player in check!");
|
||||
}
|
||||
c.showPossibleMoves(null);
|
||||
c.setSelectedPiece(null);
|
||||
}
|
||||
c.showPossibleMoves(null);
|
||||
|
|
|
@ -64,7 +64,7 @@ public class Pawn extends APiece {
|
|||
for (int directionX : new int[]{-1, 1}) {
|
||||
if(checkEnPassant(directionX) && pos.x == x+directionX) {
|
||||
APiece piece = chessboard.getPiece(x+directionX, y);
|
||||
if(piece != null) piece.remove();
|
||||
if(piece != null) piece.remove(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue