A Flash Developer Resource Site

Results 1 to 3 of 3
  1. #1
    Back to FK Boards!
    Join Date
    Apr 2006

    [MX] Hittest in MX

    hello. im used to using Flash 8 but i now have a class in school using flash. in school we only have the version MX. not 04. im trying to make a platform game to suprise my teacher and classmates. i have made them multiple times in flash 8 but im not familiar with AS in flash MX. do you think someone could provide me with codes for:

    1. hittests (and could you just tell me how to do one for future use?)
    2. jumping
    3. gravity
    4. (could you tell me how to do roots for MC's and other things also?)
    5. platforms (so you could stay on them and not fall through)
    6. adding points to your "score"

    and that should be it for now. you dont have to answer all, just 1 or 2 would be appreciated.

    thanks have a nice day. bye

    Email: Jacktown012@aim.com
    AIM: jacktown012
    MSN: megafire987@hotmail.com

  2. #2
    Senior Member pup100's Avatar
    Join Date
    Oct 2004
    Quote Originally Posted by Dark Cloud
    and that should be it for now
    Just a few minor topics then Dark Cloud!

    Hit Test All you are doing is using the condition to see if 2 objects are colliding - Put 2 movie clips on the stage red_mc & green_mc

    _root.onEnterFrame = function() {
    _root.red_mc._x += 10;
    _root.green_mc._x -= 10;
    if (red_mc.hitTest(_root.green_mc)) {

    Gravity The equation for gravity is:

    F =G*(mass1*mass2)/distance*distance applying this in Flash will make blood come out our ears! A better & just as effective way is to come up with a value for gravity & then apply that every frame:

    //set gravity
    _root.onEnterFrame=function () {
    if (ball._y > 400) {

    This adds to gravity as mentioned above an then checks the clips _y position if it is at the same level as the floor it reverses the clips downward motion.

    Platforms Just set an absolute _y position for your games through which your charaters can not pass, along the lines of if (mans._y>=100){

    Having said all that game design in Flash can be complex & complicated business for example to make platform games more efficient you would build your world out of tiles (both Platform & Iso) & check for the position/collision of a character using some pretty clever tricks. There are a few really good books on the subject I recommend Jobe Makar's "FlashMX Game design demystified" although written for MX(2000) the object orientated nature of his code should work well in 2000.
    You will know everything when you know you never will.

  3. #3
    Join Date
    Nov 2006

    to use scoring and points you just need a varible.

    on the first frame of your file put this in the actions:

    score = 0
    this creates the varible called score and makes its value 0

    to display the score:

    create a dynamic text feild and enter "score" into the "var:" box.

    to add to the score:

    you can use various methods such as hittest to add to the score. using pup100's code from above for speed:

    _root.onEnterFrame = function() {

    _root.character_mc._x += 10;

    _root.coin._x -= 10;

    if (red_mc.hitTest(_root.green_mc)) {

    score + 10 //change this to the number of points you want the player to //get when they hit the object



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