【发布时间】:2012-01-24 17:25:21
【问题描述】:
我是 Flash AS3 的新手,我在网上看到过这段代码,但它是用 AS2 编码的,任何人都可以帮助我。
onClipEvent (enterFrame)
{
distance = _root.enemy._x - _root.player._x;
if (distance < 100 && distance > -100 && _root.enemyTimer == 0)
{
a = int(Math.random() * 100);
if (a >= 0 && a < 60)
{
_root.enemy.gotoAndStop('attack1');
_root.healthbar.gotoAndStop(_root.healthbar._currentframe -= 5);
}
else if (a >= 60 && a <= 100)
{
_root.enemy.gotoAndStop('attack2');
_root.healthbar.gotoAndStop(_root.healthbar._currentframe -= 8);
}
}
if (distance < 160 && distance > 100)
{
this._xscale = _root.eScale;
_x -= 2;
}
if (distance > -160 && distance < -100)
{
this._xscale = -_root.eScale;
_x += 2;
}
}
tnx 提前我会用这个作为参考。
【问题讨论】:
-
您需要进行一些小的更改,请查看as2 to as3 migration guide(其中很多在线)以开始使用。顺便说一句,这一行:
a = int(Math.random() * 100);看起来不像 as2,在 as3 中添加了 int
标签: actionscript-3 actionscript-2