所以,我发现一些代码基本上是在我的播放器对象周围设置一个矩形跟随鼠标设置的距离。在 2D 平面上,我有角色,当玩家点击鼠标按钮时,鼠标和角色之间会出现一个盾牌。这部分有效,这里是代码:
var angle;
var track_radius = 10;
// find the angle to the mouse
angle = point_direction(self.x, self.y, mouse_x, mouse_y);
// turn the shield to look at the mouse
image_angle = angle;
// convert to radians for the math functions
angle = degtorad(angle);
// place the shield on a circular track about the player
// . track_radius is set in the create event
x = global.playerX + 50 * cos(angle);
y = global.playerY - 50 * sin(angle); // minus
因此,当鼠标靠近防护罩时,问题就出现了。护盾一分为二,映照在鼠标指针上,来回闪烁。基本上只要鼠标靠近或在盾牌存在的半径内,问题就会继续存在。还可能值得注意的是,盾牌是在单击鼠标时在玩家的位置创建的,然后使用上面的代码移动。想法?