A Flash Developer Resource Site

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    8

    resolved [RESOLVED] Gravity and Ground hitTest

    Alright, so I am working on a smooth gravity script, with multiple grounds, so far it was working pretty well, until i tried to add in a second ground MC, here was my code for the gravity section at first, it worked fine :

    onClipEvent (enterFrame) {
    if ((this.frontleg.hitTest (_root.ground.topg)) && (this._y -= 0)) {
    this._y += 0;
    if (this.frontleg.leg._currentframe == 15) {
    this.frontleg.gotoAndStop (1);
    this.backleg.gotoAndStop (1);
    this.frontarm.gotoAndStop (1);
    this.backarm.gotoAndStop (1);
    }
    if (Key.isDown (Key.UP)) {
    _root.knight.frontleg.gotoAndStop (3);
    _root.knight.backleg.gotoAndStop (3);
    _root.knight.frontarm.gotoAndStop (3);
    _root.knight.backarm.gotoAndStop (3);
    }
    }else{
    if (this.frontleg._currentframe == 3) {
    }else{
    this._y += 8;
    }
    }
    if (this.torso.hitTest (_root.ground.leftg)) {
    this._x -= 9;
    }
    if (this.torso.hitTest (_root.ground.rightg)) {
    this._x += 9;
    }
    if (this.knighthead.hitTest (_root.ground.bottomg)) {
    _root.knight.frontleg.lj.gotoAndStop (15);
    _root.knight.backleg.lj.gotoAndStop (15);
    }
    }

    Then I tried to add this and neither of the grounds would work anymore :

    onClipEvent (enterFrame) {
    if ((this.frontleg.hitTest (_root.ground1.topg)) && (this._y -= 0)) {
    this._y += 0;
    if (this.frontleg.leg._currentframe == 15) {
    this.frontleg.gotoAndStop (1);
    this.backleg.gotoAndStop (1);
    this.frontarm.gotoAndStop (1);
    this.backarm.gotoAndStop (1);
    }
    if (Key.isDown (Key.UP)) {
    _root.knight.frontleg.gotoAndStop (3);
    _root.knight.backleg.gotoAndStop (3);
    _root.knight.frontarm.gotoAndStop (3);
    _root.knight.backarm.gotoAndStop (3);
    }
    }else{
    if (this.frontleg._currentframe == 3) {
    }else{
    this._y += 8;
    }
    }
    if (this.torso.hitTest (_root.ground1.leftg)) {
    this._x -= 9;
    }
    if (this.torso.hitTest (_root.ground1.rightg)) {
    this._x += 9;
    }
    if (this.knighthead.hitTest (_root.ground1.bottomg)) {
    _root.knight.frontleg.lj.gotoAndStop (15);
    _root.knight.backleg.lj.gotoAndStop (15);
    }
    }

    Any Idea what happened?

  2. #2
    Junior Member
    Join Date
    May 2012
    Posts
    8
    Bump, anyone have an idea what I`m doing wrong?

  3. #3
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,770
    Post FLA file
    17 Years old boy, who loves the Computer Technology

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  4. #4
    Junior Member
    Join Date
    May 2012
    Posts
    8
    Sorry, I fixed it.

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