Chess.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:gamecollection 作者:
private boolean animatefigure(final Tuple<Integer, Integer> from, final Tuple<Integer, Integer> to, int speed) {
    if (figuren[from.first][from.last] != null) {
        Point rectFrom = chessboardView.getRectangleCoordinates(from);
        Point rectTo = chessboardView.getRectangleCoordinates(to);
        int deltaX = rectTo.x - rectFrom.x;
        int deltaY = rectTo.y - rectFrom.y;
        TranslateAnimation translateAnimation = new TranslateAnimation(0, deltaX, 0, deltaY);
        translateAnimation.setDuration(speed);
        translateAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
        translateAnimation.setAnimationListener(new AnimationEndListener() {
            @Override
            public void onAnimationEnd(Animation animation) {
                update();
                if (aiGame && !board.isWhitesTurn()) {
                    aimove();
                } else {
                    stateAllowClick = true;
                }
            }
        });
        figuren[from.first][from.last].startAnimation(translateAnimation);
        return true;
    }
    return false;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号