我陷入了as3命中測試問題。這是我在as2中編寫的代碼。請幫助我將其遷移到as3AS2到AS3 hitTest遷移
target.hitTest((_x - _width/2) * (1/(100/_root.game._xscale)) + _root.game._x,
_y * (1/(100/_root.game._yscale)) + _root.game._y, true)
我陷入了as3命中測試問題。這是我在as2中編寫的代碼。請幫助我將其遷移到as3AS2到AS3 hitTest遷移
target.hitTest((_x - _width/2) * (1/(100/_root.game._xscale)) + _root.game._x,
_y * (1/(100/_root.game._yscale)) + _root.game._y, true)
_root,_levelX等確實存在於AS3中。您需要將_root替換爲包含「遊戲」對象的對象的引用。如果「遊戲」對象處於階段級別,那麼對於大多數情況,您可以使用game.stage.prop/meth。
另一件重要的事情,_xscale/_scale接受的百分比爲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」是參照對象中,保持「遊戲」的DisplayObject(影片剪輯,子畫面或其他)。
希望有所幫助。
-abdul
非常感謝你 – Kombuwa 2009-11-25 07:40:43
在AS3中,很多變量都會更改您的名稱。你有沒有聲明的變量_x,_width,_root,_xscale,_y和_yscale?
如果沒有,那麼這就是你的問題,你要做的就是改變這些對正確的新變量:X,寬度,根(階段會更好),的scaleX ,和和scaleY。
此外,也不再則hitTest方法,相反,你應該使用hitTestObject或hitTestPoint。
你也應該看看這個網址:http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/migration.html
乾杯, CaioToOn!
你編譯as3時遇到什麼樣的問題? – AaronLS 2009-11-20 05:37:05