A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: hittest-ish question...

  1. #1
    file not found Captain_404's Avatar
    Join Date
    Apr 2006
    Posts
    457

    detecting multiple mc contacts (collisions, touches, etc?)...

    I'm wondering if there is anyway to recognise if an mc is touching any other mc (with OR without an instance name) at all.

    Basically, can an mc recognize if it touches any other non-specific mc within it's layer?

    I'm using Flash MX 2004

    I would really apreciate any help I could get.

    even if the answer is no
    Last edited by Captain_404; 04-26-2006 at 08:16 PM. Reason: title seemed misleading

  2. #2
    Robot Master the--flash's Avatar
    Join Date
    Jul 2005
    Location
    The year 20XX...
    Posts
    132
    I have MX 2004 as well, and only I'm pretty such (almost positive) only MCs with instance names can be detected for hittest. The code goes as such...

    code:
    if (_root.MCHERE.hitTest(this)) {



    put the MC in the MCHERE part.

    Hope this helps!

    EDIT: made a mistake!
    Last edited by the--flash; 04-26-2006 at 08:39 PM.

  3. #3
    Death to anime
    Join Date
    Mar 2006
    Location
    Holland, MI
    Posts
    32

    A little tip

    Use this tutorial for help. To learn how to use mass collision testing, go to this tutorial: http://www.flashkit.com/tutorials/Math-Physics/Mass_Col-Dennis_S-623/index.php

  4. #4
    Senior Member
    Join Date
    Apr 2006
    Posts
    1,059
    afaik every MC on stage has an instance name(to flash...maybe not one you put there(usually it defaults to something like instance1 or something..i think..)

    something like

    for (key in _root){
    _root[key].hitTest(this)
    }

    should hit every movieclip on the main timeline..if you have movieclips inside movieclips then your gonna need something else but the code above should hittest against EVERYTHING in the root timeline(maybe even itself? )

  5. #5
    file not found Captain_404's Avatar
    Join Date
    Apr 2006
    Posts
    457
    Quote Originally Posted by joran420
    for (key in _root){
    _root[key].hitTest(this)
    }
    This does indeed work, however, as you predicted, it even tests for itself.

    So, would there be any way to say: "check for everything, except yourself" in actionscript, basically, is there any way I can omit the mc that needs to check for hits from the search?

  6. #6
    Senior Member
    Join Date
    Apr 2006
    Posts
    1,059
    hehe you may want to pick up an actuall class or book on programming...but yeah

    you would just add a
    if(this != root[key]){modify _root[key] thing here}

    alternatively you could just create a big movieclip and call it targets and place all the things you want to check inside

    the do

    for( key in targets){
    if(targets[key].hittest(this)){//bust a move}
    } or you could shove the objects you want to hitTest into an array(when theyre created) and run through the array with a for loop (its all explained in the tutorial posted above)

    but seriously man doesnt matter what programming language you learn youll pick up some valuable concepts(try picking visual basic,c++,javascript, Lua , or actionscript)
    as the main thing you want to learn in concepts and its fairly easy to follow with those languages...(actionscript would prolly be best since your trying to do flash stuff...but it may be harder(or more expensive) to find one of those)
    [edit] damn reading it over its kinda harsh ...i didnt mean it in a bad way :P
    Last edited by joran420; 04-30-2006 at 02:18 PM.

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