碰撞检测在Flash的功能? (hitTestObject) [英] Collision Detection in Flash Functionalities? (hitTestObject)

查看:708
本文介绍了碰撞检测在Flash的功能? (hitTestObject)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 你好,我最近一直在使用 hitTestObject 来检测碰撞在一个Android应用程序我正在做。测试了一下后,我意识到,比赛被检测的假的碰撞。我的意思是,它是检测到碰撞的不可以当一个对象(S)的像素是感人的,但是(做了一些研究之后)我发现原来的的碰撞,其中的对象。所以,我有游戏停止了碰撞,这就是它的样子:
  • Hello, so I've been recently using hitTestObject to detect collisions in an android app I'm making. After testing for a bit, I realized that the game was detecting "fake" collisions. What I mean by this is that it was detecting a collisions not when the pixels of an object(s) are touching, but (after doing a bit of research) I found out that the boxes of the objects where colliding. So I had the game stop with a collision, and this is how it looks like:

我试图勾勒出两个目标的盒子,更清晰。正如你可以看到他们的的是感动。有没有办法把它检测时的像素的碰撞?

I tried outlining the two object's boxes, for clarity. As you can see their boxes are touching. Is there any way to have it detect when pixels collide?

  • 在我以为会有网上的东西,但我不知道是什么。该游戏是通过操作窗口,而不是一类文件编写,所以没有包,也不类,和任何碰撞检测功能的在线,即需要一个类的工作,可能不会在这里工作。

总之:有没有办法在ActionScript 3,检测的像素的碰撞,如果是的话。我可以使用什么功能和/或命令?

Anyway: is there any way in actionscript-3 to detect pixels colliding, and if so. What function and/or command could I use for that?

推荐答案

当你正确地注意到,灾区在默认情况下为矩形,因为它们使用的边框。

As you correctly notice, hit areas in hitTestObject are by default rectangular, as they use the bounding box.

您可以使用在逐点的基础测试的对象的实际形状......

You can test against the object's actual shape on a point-by-point basis using...

hitTestPoint(someobject.x, someobject.y, true);

(见<一href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#hitTestPoint%28%29"相对=nofollow>文档。)

有关定制形严重的地区,还可以使用位图命中测试。 (看到这里接受的答案。

For custom-shaped hit areas, you can also use bitmap hit testing. (See accepted answer here.)

这篇关于碰撞检测在Flash的功能? (hitTestObject)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆