Craig
Craig

Reputation: 51

Bitmap Collision Detection(AS3)

I have some bitmaps, one of the character and the other of spikes. I'm wanting to detect when the character bitmap collides with the spikes. The spike bitmaps are added to an array because there's so many of them. I've read things like this: http://www.mikechambers.com/blog/2009/06/24/using-bitmapdata-hittest-for-collision-detection/

But that uses BitmapData and draws the bitmaps. Mine are embedded from PNGs. For example:

[Embed(source="../lib/NewChar.png")]
    public var CharImage:Class;

public var char:Bitmap = new CharImage();

How would I go about this or maybe I'm just missing something?

Upvotes: 0

Views: 57

Answers (1)

Cyclonecode
Cyclonecode

Reputation: 29991

Since embedded bitmaps is represented by the BitmapAsset class you should be able to access your embedded image data through the bitmapData property:

public var img:Bitmap = new CharImage();

var data:BitmapData = img.bitmapData;

Upvotes: 1

Related Questions