Search code examples
flashactionscript-3bitmapdata

How to properly use hitTest between bitmapData and an object?


I have converted a PNG into a bitmap, then converted that into bitmapData.

I have a object called _player, and I wish to add collision detection, however I can seem to get it to work.

my code is:

if(bmd1.hitTest(new Point(_player.x, _player.y))){
trace("hit");
}

bmd1 is my bitmapData,_player is the object is wish to test against.

I am getting the following error:

1136: Incorrect number of arguments, Expected 3

I have looked around but cannott find what argument I am missing

Any ideas?

Update

I have tried

if(bmd1.hitTest(new Point(_player.x, _player.y), 50, _player)){
trace("hit");
}

with no joy

Update 2

Sorry, I should mention that the reason for me taking this approach is that I have a PNG, with transparent areas, I need to test for collisions in the non-transparent areas, which is why I was using this approach

I have a PNG, i import that and convert to bitmap, then convert to bitmapData

I maybe doing this completely wrong. Could you show me where the problem lies?


Solution

  • In the end I converted my player movieclip to bitmapdata, converted my png map to bitmap data, then used hitTest to check the x and y of each bitmap against each other