A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Hittest Not Working!!!!!!!!!!!

  1. #1

    Angry Hittest Not Working!!!!!!!!!!!

    Hey..

    I have a duplicating movieclip (acting as bullets) that shoot across the screen from a turret blah blah blah.. Their names are set as "bullet"+bulletcount; and everytime one is shot bullet++; and the result is many bullets called bullet1, bullet2, bullet3, bullet4 etc etc..

    how do i get this to hit my wall i used the code

    onEnterFrame = function() {
    if ("bullet"+bulletcount.hitTest(_root.wall)) {
    trace("hit")
    }
    }

    However my code is not called as the bullets will pass straight over the wall and the code is called as soon as you fire the bullet....Why

    Any help is appreciated..
    Last edited by hopies; 09-04-2008 at 02:08 PM.
    The one that smiles when things go wrong, Has thought of someone to blame it on

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Correct code would be getChildByName("bullet" + n))...

    But - using string lookups is really really slow for the processor...you'd be much better off putting the bullets into an array instead of using .name. And if you use array.push(new Bullet()) your bulletcount should stay synched with the array index...eg. bulletArray[10] = bullet10;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center