Search code examples
flashflash-cs5flashdevelop

Circle objects detected as square in hitTestObject


So i'm learning the basics of Flash game dev. I've built a simple avoider game, use the mouse to move a circle, avoiding falling objects. Only issue is, flash thinks its square. So for example, there's an invisible corner to my circle, which touches one of the falling objects, however, from a player perspective, you never touched that object.How do I resolve this so its masked as a circle I guess, not a square object.

Image with further explanation. https://i.sstatic.net/Xuoik.png


Solution

  • For this you will need to read up with out any thorough code or explanation.

    whats happening is you are detecting a boundary box of an object. Think of a png image with a circle in the middle, the image is a square or rectangle but there's an alpha channel to make the image only show the circle of the picture so if you were to touch this item you will be touching the whole object which alpha channel is part of the object (thats the boundary box).

    You should look at different methods to detect collisions, depending on how you want to handle this. My self i would look at pixel collision and for simple shape there's plenty of examples out there: )