How to communicate with another mc on hitTest?
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: How to communicate with another mc on hitTest?

  1. #1
    Junior Member
    Join Date
    Apr 2002
    Location
    Chicago
    Posts
    13

    How to communicate with another mc on hitTest?

    I am creating a side scrolling platform game using the book "Flash Game University" by Gary Rosenzweig.

    I have my player character called "hero".
    My spring object is a movie clip with 3 frames each with a different label: start, down, up. When my hero collides with the spring I want to programmatically instruct the spring to go to the second frame and start to play. I then want the spring to make me jump in the air 2-3 times higher than my normal jump can do. The third piece is how to make the collision occur only when the hero jumps on the top of the spring and not by running into it from the sides?

    Does anyone have a solution?

    Thanks,
    Alex
    Alex Dove
    A Web Development Company
    www.pivotalsolution.com
    alex.dove@pivotalsolution.com

  2. #2
    President PhobiK's Avatar
    Join Date
    Jan 2005
    Location
    Guatemala
    Posts
    918
    This is a way to do so. I'm assuming you're doing it in AS2, but slight changes may apply for AS3 (x instead of _x, hitTestObject instead of hitTest). Adapt accordingly as I don't know where those mc's are located (_root or somewhere else).
    Code:
    if (hero.hitTest(spring) && hero._x < (spring._x + spring._width/2) && hero._x > (spring._x - spring._width/2) && hero._y < spring._y) {
    hero.gravity = hero.jump * 3;
    spring.gotoAndPlay(2); // or "down", whichever is the case
    }
    This is MC. His _parents sent him to stop() by the super market to buy some _root beer if he wanted to gotoAndPlay() with his friends at the park later.

    This is my Blog!... The gaming Process
    Please check out my site: Giddel Creations

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

Poll by Flashkit.com