A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Hittest Help Please {!}

  1. #1
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870

    Hittest Help Please {!}

    Can anyone here suggest a code so that a Hittest is done on a finishing line and a car? P.S. The user drives the car around the track, Hitting several checkpoint(or Hittested-lines) then hit the finishing line... which stops a count-down clock.
    So basically I got a car instance name "car" and 5 different lines named (L1, L2, L3... L5) and a finishing line instance: "Fini1"

    Thanks for any imputs,
    Merry Christmas guyz,
    Tongxn
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  2. #2
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Hey tongxn,

    Here's the code for a basic hitTest. You would put the following code on your car itself:

    code:

    if (this.hitTest(_root.finishLine)){
    trace("FINISH");
    }



    Now all you have to do is modify it so that it counts and makes sure all the checkpoints have been touched by using hitTests to see the car ran over them

  3. #3
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    what does trace do here?
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  4. #4
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    uh oh.. I don't think it works, i put this action into the main timeline:

    if(car.hitTest.c1)
    //c1 is checkpoint 1
    l1.gotoAndStop(5)
    //l1 is the light,

    is there something wrong? or should I use "_root.l1.goto....."

    It's nearly finished guys I only need to get over this hurdle to complete this project!
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  5. #5
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Hey,

    A trace is just used to see if something works, it'll just display something in the output window during run time debugging. For example if you put: trace("hey"); it'll display the word 'hey' in the output window.

    As for your code, if its in the main timeline it will have to look a little something like this:

    code:

    onEnterFrame = function (){
    if (_root.car.hitTest(_root.c1)){
    _root.l1.gotoAndStop(5);
    }
    }



    Give that a try and happy new year !

  6. #6
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    ah thanks a lot Osteel!
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  7. #7
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    No problem tongxn,

    Good luck with your project

  8. #8
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    oh no i don't think it's properly working...
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  9. #9
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    i can't get the function up
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  10. #10
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    oh wait - YES! - i got it!
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

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