画出开始画面和结束位置之间的路径

时间:2017-12-24 07:26:27

标签: android

我正在使用arduino和android studio创建室内位置应用程序。 Arduino使用Bluetooth将室内位置坐标发送到Android手机。 enter image description here

使用以下java类

创建地图
public class MazeCreator {

public static Maze getMaze(int mazeNo) {
    Maze maze = null;

        maze = new Maze();
    if(GameView.floorval== false) {
        boolean[][] vLines = new boolean[][]{
                {false, false, false, true, false, true, false, false, false},
                {false, false, false, true, false, false, false, false, false},
                {false, false, false, false, false, true, false, false, false},
                {false, false, false, true, false, false, false, false, false},
                {false, false, false, false, false, true, false, false, false},
                {false, false, false, true, false, true, false, false, false},
                {false, false, false, true, false, false, false, false, false},
                {false, false, false, false, false, true, false, false, false},
                {false, false, false, true, false, true, false, false, false},
                {false, false, false, true, false, true, false, false, false}


        };
        boolean[][] hLines = new boolean[][]{
                {false, false, false, false, false, false, false, false, false, false},
                {false, true, true, true, false, false, false, false, false, false},
                {true, false, true, true, false, false, true, true, true, true},
                {true, true, true, true, false, false, true, true, false, true},
                {false, false, false, false, false, false, false, false, false, false},
                {false, false, false, false, false, false, true, true, true, true},
                {true, true, true, true, false, false, true, true, true, true},
                {false, false, false, false, false, false, false, false, false, false},
                {false, false, false, false, false, false, false, false, false, false}
        };
        maze.setVerticalLines(vLines);
        maze.setHorizontalLines(hLines);
        Log.d("Maze 1=" ,Integer.toString(mazeNo) );

        if (mazeNo == 1) {
            maze.setStartPosition(0, 0);
            maze.setFinalPosition(2, 7);
        }

        if (mazeNo == 2) {
            maze.setStartPosition(0, 0);
            maze.setFinalPosition(2, 4);
        }
        if (mazeNo == 3) {
            maze.setStartPosition(0, 0);
            maze.setFinalPosition(1, 3);
        }
        if (mazeNo == 4) {
            maze.setStartPosition(0, 0);
            maze.setFinalPosition(0, 0);
        }
        if (mazeNo == 5) {
            maze.setStartPosition(0, 0);
            maze.setFinalPosition(7, 1);
        }
        if (mazeNo == 6) {
            maze.setStartPosition(0, 0);
            maze.setFinalPosition(8, 4);
        }
        if (mazeNo == 7) {
            maze.setStartPosition(0, 0);
            maze.setFinalPosition(8, 7);
        }
    }

    else {

        boolean[][] vLines = new boolean[][]{
                {false, false, false, true, false, true, false, false, false},
                {false, false, false, true, false, false, false, false, false},
                {false, false, false, false, false, true, false, false, false},
                {false, false, false, true, false, true, false, false, false},
                {false, false, false, false, false, true, false, false, false},
                {false, false, false, true, false, false, false, false, false},
                {false, false, false, false, false, false, false, false, false},
                {false, true, true, false, false, true, true, false, false},
                {false, true, true, false, false, true, true, false, false},
                {false, false, true, false, false, true, true, false, false}


        };
        boolean[][] hLines = new boolean[][]{
                {false, false, false, false, false, false, false, false, false, false},
                {false, true, true, true, false, false, false, false, false, false},
                {true, false, true, true, false, false, true, true, true, true},
                {true, true, true, true, false, false, false, false, false, false},
                {false, false, false, false, false, false, true, true, false, true},
                {true, true, true, true, false, false, false, false, false, false},
                {true, true, false, true, false, true, false, true, false, true},
                {false, false, false, false, false, false, false, false, false, false},
                {false, false, false, false, false, false, false, false, false, false}
        };
        maze.setVerticalLines(vLines);
        maze.setHorizontalLines(hLines);

        if (mazeNo == 8) {
            maze.setStartPosition(0, 0);
            maze.setFinalPosition(0, 0);

        }
        if (mazeNo == 9) {
            maze.setStartPosition(0, 0);
            maze.setFinalPosition(1, 4);

        }
        if (mazeNo == 10) {
            maze.setStartPosition(0, 0);
            maze.setFinalPosition(8, 8);
        }
        if (mazeNo == 11) {
            maze.setStartPosition(0, 0);
            maze.setFinalPosition(4, 8);
        }
        if (mazeNo == 12) {
            maze.setStartPosition(0, 0);
            maze.setFinalPosition(0, 8);
        }
        if (mazeNo == 13) {
            maze.setStartPosition(0, 0);
            maze.setFinalPosition(8, 3);
        }
    }
    return maze;
}
}
人指示的

current location和最终位置表示蓝色圆圈。现在我想draw pathcurrent location到最终位置。请帮帮我

1 个答案:

答案 0 :(得分:0)

怎么样:

How to draw a line in android

画出你的台词。使用onLocationChanged(我的意思是位置监听器)激活它,从最后一个位置绘制到新位置(保护变量中的旧位置)并在获得新位置时覆盖它。