A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Gone and got stuck need direction!

  1. #1
    Senior Member
    Join Date
    Feb 2001
    Posts
    110
    Okay guys,

    I've got a ball mc in the centre of the screen with the ground mc moving around and a car mc inside the ground mc.

    When ball mc hits car mc it bounces off.

    The only problem is I can only have one car. I can't copy and paste a bunch of cars in the ground mc to bounce off because only the original one works.

    I based the coding idea on Mad sci's platform engine where you can copy and paste platforms. But mine doesn't work.

    Here's the code:

    IN THE GROUND MC

    onClipEvent (load) {
    mover = 5;
    whack = "off";
    }
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.LEFT)) {
    this._x += mover;
    }
    if (Key.isDown(Key.RIGHT)) {
    this._x -= mover;
    }
    if (Key.isDown(Key.UP)) {
    this._y += mover;
    }
    if (Key.isDown(Key.DOWN)) {
    this._y -= mover;
    }
    if (whack eq "on") {
    mover = -10;
    }
    if (whack eq "off") {
    mover = 5;
    }
    }


    IN THE CAR MC INSIDE GROUND MC (it hasn't been given any instance name)

    onClipEvent (enterFrame) {
    if (hitTest(_root.ball)) {
    _root.ground.whack = "on"
    } else {
    _root.ground.whack = "off"
    }
    }

    THE BALL IS EMPTY (Apart from instance name)


    Any ideas guys?

    Cheers.


  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    I hope this works.

    In second car use

    onClipEvent (enterFrame) {
    if (hitTest(_root.ball)) {
    _root.ground.whack2 = "on"
    } else {
    _root.ground.whack2 = "off"
    }
    }

    And in ground mc:

    if (whack eq "on" or whack2 eq "on") {
    mover = -10;
    }
    if (whack eq "off" and whack2 eq "off") {
    mover = 5;
    }

    More cars? Just keep adding them same way.
    Only problem will be, I think, all your cars will bounce, if 1 of them hits the ball. Still, you could try it

  3. #3
    Senior Member
    Join Date
    Feb 2001
    Posts
    110
    Thanks for your help mate, but unfortunately it activates the second car and ignores the first one!

    Bloody code!

    I've just been looking at the GTA code.

    I think I can get something from that.


    Cheers anyway.




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