我已经开始使用 ActionScript 编写代码,并尝试编写此程序。它会在舞台上绘制一个形状,您可以使用箭头键移动它。我添加了一个“边缘粘贴”功能,将一半的形状粘贴到边缘。这是我的代码:
function freemove(event:KeyboardEvent):void
{
switch (event.keyCode)
{
case Keyboard.UP:
{
testing.y -= 5;
if(testing.y < stage.width)
{
testing.y = 0;
}
break;
}
case Keyboard.DOWN:
{
testing.y += 5;
// FOR BOTTOM EDGE.
break;
}
case Keyboard.LEFT:
{
testing.x -= 5;
if(testing.x < stage.height)
{
testing.x = 0;
}
break;
}
case Keyboard.RIGHT:
{
testing.x += 5;
// FOR RIGHT EDGE.
break;
}
}
}
问题是:它只适用于左边缘和上边缘。我怎样才能使它适用于底部和右侧边缘?谢谢!=)