【问题标题】: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)
【问题讨论】:
标签:
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 或其他)的对象的引用。
希望对您有所帮助。
-阿卜杜勒