【发布时间】:2014-01-15 01:02:49
【问题描述】:
我正在制作一个带有 2 个动画的 Flash 游戏。站立动画和移动动画。我希望如果有人按下上下左右箭头然后播放移动动画,如果没有按下这些键则播放站立动画。
我用过:
stage.addEventListener(KeyboardEvent.KEY_DOWN, movingAnimation);
function movingAnimation(event:KeyboardEvent):void
{
if (event.keyCode == 37)
{
account_animation.gotoAndPlay("moving");
}
if (event.keyCode == 38)
{
account_animation.gotoAndPlay("moving");
}
if (event.keyCode == 39)
{
account_animation.gotoAndPlay("moving");
}
if (event.keyCode == 40)
{
account_animation.gotoAndPlay("moving");
}
}
stage.addEventListener(KeyboardEvent.KEY_UP, standingAnimation);
function standingAnimation(event:KeyboardEvent):void
{
if (event.keyCode == 37)
{
account_animation.gotoAndPlay("standing");
}
if (event.keyCode == 38)
{
account_animation.gotoAndPlay("standing");
}
if (event.keyCode == 39)
{
account_animation.gotoAndPlay("standing");
}
if (event.keyCode == 40)
{
account_animation.gotoAndPlay("standing");
}
}
这不起作用。我在这里做错了什么?
【问题讨论】:
-
这段代码在你的时间线上我接受吗?
标签: actionscript-3 flash