大家好,下面是我移动角色 player_mc 的代码,它可以很好地在屏幕上移动,但我无法阻止他离开屏幕。据我了解,如果 playermc = x> 舞台宽度减少 5 增加 5 等,并且与 y 相同,但为什么这对我不起作用?你们能告诉我我在这里做错了什么吗?您可以看到标记为不作为注释工作的代码。谢谢,如果您想查看完整代码,这里是我问的另一个问题的链接: https ://stackoverflow.com/questions/16764305/educational-simulation-actionscript-2
function rotatePlayer()
{
//calculate player_mc rotation, based on player position & mouse position
player_mc._rotation = Math.atan2(_ymouse - player_mc._y, _xmouse - player_mc._x) * radians2;
// not working code: stage collision.
if (player_mc._x > stage.width)
{
player_mc._x+50
}
if (Key.isDown(Key.RIGHT))
{
player_mc._x += 5;
}
else if (Key.isDown(Key.LEFT))
{
player_mc._x -= 5;
}
else if (Key.isDown(Key.UP))
{
player_mc._y -= 5;
}
else if (Key.isDown(Key.DOWN))
{
player_mc._y += 5;
}
}