A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [mx]

  1. #1
    Junior Member
    Join Date
    Mar 2007
    Posts
    4

    [mx]

    I Am using Flash MX.

    IM trying to make a side scrolling platformer game where you jump platforms.

    I found a tutorial. it says make a ball. then make a rectanglle and name it Ground, then select the ball and enter the folling code:

    onClipEvent (load) { moveSpeed = 10;}onClipEvent (enterFrame) { if (Key.isDown(Key.RIGHT)) { this._x += moveSpeed; } else if (Key.isDown(Key.UP)) { this._y -= 0; } else if (Key.isDown(Key.DOWN) && !fall) { this._y += 0; } else if (Key.isDown(Key.LEFT)) { this._x -= moveSpeed; }}onClipEvent (enterFrame) { if (Key.isDown(Key.SPACE) && !jumping) { vel_y = 36; jumping = true; } if (jumping == true) { vel_y -= 2; if (vel_y<=-15) { vel_y = -15; } this._y -= vel_y; } if (_root.ground.hitTest(this._x, this._y+35, true)) { vel_y = 0; jumping = false; }}onClipEvent (enterFrame) { this._y += 16; if (_root.ground.hitTest(this._x, this._y+1, true)) { this._y -= 16; }}

    Sorry about the messiness of the code, but it was the best i can find via google.

    anyway, my ball will land on the 1st platform, but it will not land on any second platform i make. it will just fall through. I had that problem with every tutorial i can find.

    Here is a link to the tutorial:
    http://www.deviantart.com/deviation/19545486/

    I been stuck trying to figure out how to make my little ball jump on multiple platforms. Help would be apretiated.

  2. #2
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    Howdy, heres a quick fix for your problem. I made another ground and called it ground2.

    code:
    onClipEvent (load) {
    moveSpeed = 10;
    }
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.RIGHT)) {
    this._x += moveSpeed;
    } else if (Key.isDown(Key.UP)) {
    this._y -= 0;
    } else if (Key.isDown(Key.DOWN) && !fall) {
    this._y += 0;
    } else if (Key.isDown(Key.LEFT)) {
    this._x -= moveSpeed;
    }
    if (Key.isDown(Key.SPACE) && !jumping) {
    vel_y = 36;
    jumping = true;
    }
    if (jumping == true) {
    vel_y -= 2;
    if (vel_y<=-15) {
    vel_y = -15;
    }
    this._y -= vel_y;
    }
    if (_root.ground.hitTest(this._x, this._y, true)) {
    vel_y = 0;
    jumping = false;
    }
    if (_root.ground2.hitTest(this._x, this._y, true)) {
    vel_y = 0;
    jumping = false;
    }
    this._y += 16;
    if (_root.ground.hitTest(this._x, this._y+1, true)) {
    this._y -= 16;
    }
    if(_root.ground2.hitTest(this._x, this._y+1, true)){
    this._y -= 16
    }
    }


  3. #3
    Junior Member
    Join Date
    Mar 2007
    Posts
    4
    thanks a MILLION! im so glad to see someone hlp! IM gonna try it right away!


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