【问题标题】:AS2 to AS3 hitTest MigrationAS2 到 AS3 hitTest 迁移
【发布时间】:2009-11-20 05:31:53
【问题描述】:

我陷入了 as3 命中测试问题。这是我在 as2 中编​​写的代码。请帮我将它迁移到 as3

target.hitTest((_x - _width / 2) * (1 / (100 / _root.game._xscale)) + _root.game._x, 
  _y * (1 / (100 / _root.game._yscale)) + _root.game._y, true)

【问题讨论】:

  • as3编译时遇到了什么样的问题?

标签: flash actionscript-3 actionscript actionscript-2


【解决方案1】:

_root、_levelX 等确实存在于 AS3 中。您需要将 _root 替换为包含“游戏”对象的对象的引用。如果“游戏”对象处于舞台级别,您可以使用 game.stage.prop/meth,大部分情况。

另一个重要的事情,_xscale/_yscale 接受百分比为 1 到 100 等等,而 scaleX 和 scaleY 接受 0 到 1 等等。

target.hitTestPoint ((x - width/2) * (1/rootApp.scaleX) + rootApp.game.x, y * (1/rootApp.game.scaleY) + rootApp.game.y, true);

其中“rootApp”是对持有“游戏”显示对象(movieclip、sprite 或其他)的对象的引用。

希望对您有所帮助。

-阿卜杜勒

【讨论】:

    【解决方案2】:

    在 AS3 中,许多变量都更改了您的名称。您是否声明了变量 _x_width_root_xscale_y_yscale?

    如果不是,那么这就是你的问题,你所要做的就是为正确的新变量更改这些:xwidthroot em>(stage会更好)、scaleXyscaleY

    另外,不再有 hitTest 方法,而是应该使用 hitTestObjecthitTestPoint

    你也应该看看这个网址:http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/migration.html

    干杯, CaioToOn!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-28
      • 2018-04-19
      • 1970-01-01
      • 2015-08-04
      相关资源
      最近更新 更多