when you hit test with points it is important that the point being tested is relative to the object being tested against, eg
当你用点击测试时,测试点与被测对象相关是很重要的,例如
if(mountain.hitTestPoint(this.x + circle1.x, this.y + circle1.y))
if(mountain.hitTestPoint(this.x + circle1.x,this.y + circle1.y))
will return true if the circles are inside the object calling the function because their position relative to the mountain is now relative to it rather then relative to the ships xy position within the clip... hope that makes sense.
如果圆圈位于调用函数的对象内部,则返回true,因为它们相对于山的位置现在相对于它而不是相对于剪辑中的xy位置...希望这是有道理的。
btw I have done this myself in the past but I would have to remind you that you can only hit test with the points so there is no need to have circles, use blank sprites instead and set the visible flag in the properties panel to false, no drawing will make it slightly faster... not that you will notice, also sprites/graphics use less memory then movie clips.
顺便说一下,我自己过去也做过这个,但是我必须提醒你,你只能用点进行测试,所以不需要有圆圈,而是使用空白精灵,并将属性面板中的可见标志设置为false,没有绘图会让它稍微快一点......不是你会注意到,精灵/图形使用的内存比电影剪辑少。
also I would recommend hard coding some points in the clips rather then actually adding the clips in the sprite/clip itself, this will make it easier to work with them and scale later on (believe me this will annoy the hair from your head to do something later and slow the game to scale on the fly)
我还建议硬编码片段中的一些点,而不是实际添加片段/片段中的片段,这样可以更容易地使用它们并稍后进行缩放(相信我会惹恼你脑袋里的头发)以后的东西,慢慢地让游戏在飞行中缩放)
try something like this... you can determine the points values by adding a clip to the movie clip and getting its position from the properties if you must.
尝试这样的事情......你可以通过向影片剪辑添加剪辑并从属性中获取其位置来确定点值(如果必须)。
private var hitPoints:Vector. = new Vector.
hitPoints.push(new Point(10, 40));
hitPoints.push(new Point(30, 40));
//...do this for all your points
//loop through all your points and check if the hit relative to the ships position.
for(var i:int = 0; i
in this code you will need to make sure the scene object is a reference to your scenery at the bottom of the screen.
在此代码中,您需要确保场景对象是对屏幕底部的场景的引用。
I hope this helps but if this is not enough help then you should post some of your code here so we can have a look and see where it can be improved.
我希望这有帮助,但如果这还不够,那么你应该在这里发布一些代码,这样我们就可以看看它可以改进的地方了。