# Going from hittest to bitmapdata hittest

**URL:** <https://forum.kirupa.com/t/going-from-hittest-to-bitmapdata-hittest/296696>\
**Category:** programming\
**Created:** [September 18, 2009, 12:48pm UTC](https://forum.kirupa.com/t/going-from-hittest-to-bitmapdata-hittest/296696 "2009-09-18T12:48:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![olemann89](https://avatars.discourse-cdn.com/v4/letter/o/8e8cbc/32.png) [@olemann89](https://forum.kirupa.com/u/olemann89)\
**Post date:** [September 18, 2009, 12:48pm UTC](https://forum.kirupa.com/t/going-from-hittest-to-bitmapdata-hittest/296696/1 "2009-09-18T12:48:31Z")

</div>

I am in the process of making a side-scrolling shooter game, and have currently made a working game- but I want to change how the hittest is done.

So I decided on going for pixel-based collison detection, with BitmapData.  
I have a working example of the new collision detection([http://www.megaupload.com/?d=1XF5JIW4](http://www.megaupload.com/?d=1XF5JIW4)), but I need help with figuring out how to implement this new code(noobalert).

My game as of now only uses frame1 and lots of as2. My current code for spawning EnemyShip1 is:

```auto
if (enemyTimer>(60+Math.ceil(Math.random()*7))) {
enemyTimer = 0;
var enemy = _root.attachMovie("EnemyShip1", "EnemyShip1"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
    enemies.push(enemy);
   }

```

and is found in ship.as of my game.

And my current code for hittesting EnemyShip1 vs. Ship is:

```auto
if(this.hitTest(_root.ship))
    {
  if(_root.ship.shield._visible == false)
   {
   _root.ship.updateHealth(-20);
   _root.ship.initShake(); //shake effect
   }
  explode(); //removes movieclip
    }

```

and is found in EnemyShip1.as of my game.

Basically my main problem is that I dont fully understand the code in the linked fla, and therefore have little ideas as to how I can implement it? Eg. I can’t use import in a class definition, and therefore cannot use some of the code in the .fla linked. So I’m unsure if it will still be possible to spawn from ship.as, or if I will have to move over to using actions- as in the linked .fla. Any help will be greatly appreciated ;(.
