A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Car Game!

  1. #1
    Junior Member
    Join Date
    Mar 2001
    Posts
    15

    Car Game!

    Hello, I am creating a car game and this hitTest thing is really annoying me. It's not working for some reason... i have a road and grass on the outside. I want to make it so when the car hits the grass it doesn't move. In the car movie clip I have two other movie clips, both named car2... In my grass variable I basically tell _root.car.car2 to goto frame 2, which has no actions in it so the car can't move. here is the code for the grass...

    onClipEvent (enterFrame) {
    if (this.hitTest(_root.car)) {
    tellTarget ("_level0.car.car2") {
    gotoAndStop(2);
    }
    } else {
    tellTarget ("_level0.car.car2") {
    gotoAndStop(1);
    }
    }
    }


    here is the car code...

    onClipEvent (load) {

    maxspeed = 10;
    maxnegspeed = -5;
    function move(afstand) {
    draaihoek = (_rotation/180)*Math.PI;
    _x += afstand*Math.sin(draaihoek);
    _y += -afstand*Math.cos(draaihoek);
    return afstand;
    }
    }
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.UP)) {
    if (speed<maxspeed) {
    speed += 0.1;
    }
    } else {

    if (Key.isDown(Key.DOWN) == false) {
    speed *= 0.98;
    if (speed<0.1 and speed>-0.1) {
    speed = 0;
    }
    }
    }
    if (Key.isDown(Key.DOWN)) {
    if (speed>maxnegspeed) {
    speed -= 0.1;
    }
    }
    if (Key.isDown(Key.SPACE)) {
    if ((speed>=0)) {
    speed -= 0.3;
    if ((speed<=-0.1)) {
    speed += 0.3;
    if ((speed=0)) {
    (speed=0);
    }
    }
    }
    }
    if (Key.isDown(Key.LEFT)) {
    _rotation -= speed/1.3;
    }
    if (Key.isDown(Key.RIGHT)) {
    _rotation += speed/1.3;
    }

    move(speed);
    _root.speed = Math.round(speed);
    }

  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    In the car movie clip I have two other movie clips, both named car2
    This might not be good idea
    How you expect Flash to know, which 1 of those you want to send to fram2?

  3. #3
    Jedi Knight incanus's Avatar
    Join Date
    Jan 2002
    Location
    Jedi Temple, Coruscant
    Posts
    185
    in other words....... try naming one car2, and car3

    Good luck, and God bless!

    Olorin the White
    Because I'm Broken... And I'm Lonesome... And I Don't Feel Like I Am Strong Enough...

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