【发布时间】:2018-08-16 20:39:36
【问题描述】:
我正在使用 ActionScript 2 在 ADOBE FLASH CS6 上制作我的第一个平台游戏。 当我按 W + ↓ 时,我的角色会进行短跑攻击动画。
我的问题是
如果我不按住 W + ↓,动画就会中断。如果我握住它,我的性格就会不断前进。
我想要的是,
当我按住 W + ↓ 时,我希望我的角色只冲刺一次并执行完整的动画。动画完成后,如果我仍然持有正确的输入,我希望我的角色执行我之前描述的内容。
我设法正确地进行了二段跳,但我想不出解决当前问题的方法。有什么解决办法吗?
这是我的演示链接(有背景音乐):http://www.fastswf.com/tLr3bCA
输入:
- ↑(跳转)
- ↓(蹲下)
- ← / →(移动)
- 按住 Q(跑得更快)
- 太空 离地时(双跳)
- ↓ + W (SWIFT STRIKE)
这是我的角色 MovieClip 中的一部分 ActionScript (不在帧时间轴上):
{
//GENJI COMMANDS
if (Key.isDown(Key.RIGHT) && !Key.isDown(81))
{
_x += speed;
this.gotoAndStop("genjirun");
this._xscale = 100;
}
else if (Key.isDown(Key.RIGHT) && Key.isDown(81))
{
_x += speed + 5;
this.gotoAndStop("genjirunfast");
this._xscale = 100;
}
else if (Key.isDown(Key.LEFT) && !Key.isDown(81))
{
_x -= speed;
this.gotoAndStop("genjirun");
this._xscale = -100;
}
else if (Key.isDown(Key.LEFT) && Key.isDown(81))
{
_x -= speed + 5;
this.gotoAndStop("genjirunfast");
this._xscale = -100;
}
else if (Key.isDown(Key.DOWN) && touchingGround && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT) && !Key.isDown(87))
{
this.gotoAndStop("genjicrouch");
}
else if (Key.isDown(Key.DOWN) && touchingGround && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT) && Key.isDown(87) && _xscale == 100)
{
this.gotoAndStop("genjislash");
_x += 5;
}
else if (Key.isDown(Key.DOWN) && touchingGround && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT) && Key.isDown(87) && _xscale == -100)
{
this.gotoAndStop("genjislash");
_x += -5;
}
if (Key.isDown(Key.UP) && touchingGround)
{
grav = maxJump;
}
else if (!touchingGround && Key.isDown(32) && DJcancel == 0)
{
grav = -19;
DJcancel = 3;
}
else if (!touchingGround or !Doublejumping == 3)
{
this.gotoAndStop("genjijump");
}
else if (touchingGround && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT) && !Key.isDown(Key.DOWN))
{
this.gotoAndStop(1);
DJcancel = 0;
}
if (touchingGround)
{
DJcancel = 0;
}
有什么建议吗?另外,这个方法好还是我应该改变它?
【问题讨论】:
标签: flash actionscript-2