A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Need help, hitTest with BitmapData

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    2

    Need help, hitTest with BitmapData

    Hello Flash Kit, I need help please.

    -- Actionscript 2.0

    -- I'm working on a game which player have to evade the thrown stuffs. The input is webcam which captured the player into the game and process to display via the screen as a silhouette.

    I'm working on the hitTest method between the BitmapData (the player's silhouette) and the thrown stuffs (the newly created movie clip: which is moved by flash's Tween class)

    -- I googled and found that there are different parameters to put between the hitTest method of Movie Clip and the hitTest method of BitmapData

    -- Here's the tutorial I found, it's the hitTest tutorial of BitmapData.
    http://www.mikechambers.com/blog/200...sion-detection

    I got stuck, confusing and completely no idea to solve! lol

    -- I made a text box to inspect this hitTest, and the results seems to be always "HIT" (between the player's silhouette and the thrown stuff)
    I think this maybe the transparency issue, but I've tried every ways I know.

    Please make a look at the captured image and you'll get the idea.
    Here's the code of the hitTest

    Actionscript Code:
    onEnterFrame = function()   {
               
        for(j=0;j<13;j++)   {
           
            // _global.bitmap is the player's silhouette
            // and this["stuffBitmap"+j] is the newly created stuff which is being thrown by Flash's Tween class

            if(_global.theBitmap.hitTest(pt,
                                    0xff,
                                    this["stuffBitmap"+j]
                                    ))  {
                        // hit
                        amihit.text = "hit";
            } else {
                        // not hit
                        amihit.text = "not hit";
        }      
    }

    And here's some code that immediately convert the latest created movie clip to a BitmapData, which is needed to do hitTest

    Actionscript Code:
    // create the stuff
    _root.createEmptyMovieClip("stuff"+i, newdepth);
    _root["stuff"+i].attachMovie("stuff1", "stuffmc"+i, newdepth+1);

    // create bitmap data to draw the stuff
    _parent.gameRound1["stuffBitmap"+i] = new BitmapData(640, 480, true, 0xff);
    _parent.gameRound1["stuffBitmap"+i].draw(_root["stuff"+i]);


    Sorry if lack of essential information in the post.

    -- This is my project file, for the comprehensive issue inspecting
    http://www.4shared.com/file/8mIITGGf/Motionv2.html

    - The file was named PipeMotion.fla
    - The hitTest function is in the movie clip Round 1
    - The processing of the player's input to silhouette is in the _root

    Thanks a lot, for help
    Attached Images Attached Images

  2. #2
    Junior Member
    Join Date
    Sep 2010
    Posts
    2

    I got it works now

    I got it works now, thanks, everybody

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