开发者

get hitTestPoint of two childs under same parent

开发者 https://www.devze.com 2023-03-10 17:01 出处:网络
i have a parent container:Background, in it there is arbitrary amount of fishes and fish foods object added as childs, and t开发者_运维问答hey have a hit box, how can i get the coordinate of thier col

i have a parent container:Background, in it there is arbitrary amount of fishes and fish foods object added as childs, and t开发者_运维问答hey have a hit box, how can i get the coordinate of thier collision when the fish and food collide? because i want to use the coordinate to do a effect. that is to draw a ripple.Is there a method to get the coordinate of when the two hitboxes in my Food and Fish symbol when they collide.

public function moveToFood():void
        {


            x -= (x - foodTarget.x) / 40;
            y -= (y - foodTarget.y) / 40;
            if (hit.hitTestObject(foodTarget.hit))
            {

                foodRipple.drawRipple(bg,bg.y, 10, 1);
                foodTarget.removeSelf();

            }
        }


I would recommend taking a look at "Collision Detection Kit" It may give you the pixel perfect collision point you are looking for.

http://code.google.com/p/collisiondetectionkit/


Getting exact collision detection like you describe requires a library because Flash doesn't have that built-in. One way to get there is to use Box2D.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号