Reputation: 7490
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?
Upvotes: 1
Views: 1656
Reputation: 7490
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
Upvotes: 1
Reputation: 5577
The method you want is hitTestPoint() not hitTest()
EDIT: whoops I missed that you were doing the hit test against BitmapData instead of a DisplayObject. BitmapData.hitTest() performs pixel-level detection which is pretty slow in many situations. You're probably better off putting the BitmapData into a Sprite and then using hitTestPoint()
Upvotes: 0