当我的物体跳过一块积木时,如果它不能跳过,它会粘在墙上几秒钟,然后物体稍微下降,然后再粘住,直到它落到地板上。在此期间,用户可以再次跳跃,允许他们绕过任何墙。有什么办法解决这个问题吗?
if (place_meeting(x+hsp,y,Room))
{
while (!place_meeting(x+sign(hsp),y,Room))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
//VerticalCollision
if (place_meeting(x,y+vsp,Room))
{
while (!place_meeting(x,y+sign(vsp),Room))
{
y += sign(vsp);
}
vsp = 0;上面的代码处理了游戏中的冲突,通过实验,我现在把它搞得更糟了。角色会靠着墙站着,一切都会冻结。我使用的是一个防撞面罩,但这并没有帮助。
发布于 2016-04-27 16:43:40
如果我们能看到你的跳跃/移动代码就容易多了。通常,冻结是由无限的while循环引起的,尝试添加一个限制器。
if (place_meeting(x+hsp,y,Room))
{
var a = 64;
while (!place_meeting(x+sign(hsp),y,Room) and 64 > 0 )
{
a --;
x += sign(hsp);
}
hsp = 0;
}还有,为什么你会和Room相撞?什么房间?
https://stackoverflow.com/questions/36270874
复制相似问题