-->

Bitmap hittesting in AS3

2019-09-19 10:55发布

问题:

I'm building a 16 bit game for my final project and have completed all the objects and environments, I exported all the images as png files into flash as well as my character, breaking the environment up into background, objects and foreground. I can't however find a simple tutorial explaining how to do bitmap hit testing or another simple way of making my character not be able to move into the objects.

Could someone recommend a simple tutorial or an alternative method of achieving this ?

Thanks in advance

回答1:

Take a look at this great tutorial about using BitmapData.hitTest for collision detection:

http://www.mikechambers.com/blog/2009/06/24/using-bitmapdata-hittest-for-collision-detection/

Also, if you are building a flash game I think you should look into using a Flash Game Engine, for example for 2D games, plataformers and such I'd recommend:

  • FlashPunk

  • or Flixel

Both will help you A LOT with game development specific stuff such as collision detection, user input, etc which should speed up your workflow. Hope this helps!