大家好!我是一个完全的新手,最近刚开始学习GameMaker和编程。
我正在做一个极简风格的即时战略项目。单位选择功能正常(黄色圆圈出现),移动到目标的功能也正常,但黑色的移动线(draw_line_width)就是不肯显示。
以下是我在对象中使用的代码:

Step事件:
// 1. 左键选择
if (mouse_check_button_pressed(mb_left)) {
if (position_meeting(mouse_x, mouse_y, id)) {
selected = true;
} else {
selected = false;
}
}

// 2. 右键移动指令
if (selected == true && mouse_check_button_pressed(mb_right)) {
target_x = mouse_x;
target_y = mouse_y;
}

// 3. 移动与停止
if (target_x != x || target_y != y) {
move_towards_point(target_x, target_y, spd);

// 如果单位已到达目标 - 停止并吸附坐标
if (point_distance(x, y, target_x, target_y) <= spd) {
    speed = 0;
    x = target_x;
    y = target_y;
}

}

Draw事件:
draw_self();

// 绘制黄色选择圈
if (selected == true) {
draw_set_color(c_yellow);
draw_circle(x, y, 16, true);
}

// 绘制黑色的移动线到目标
if (target_x != x || target_y != y) {
draw_set_color(c_black);
draw_line_width(x, y, target_x, target_y, 2);
}

我附上了一张游戏截图来演示问题。有人能帮我看看我遗漏了什么或哪里做错了吗?
提前非常感谢!