A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: gravity

  1. #1

    gravity

    I need to know how to make gravity in flash, Like a 2d mario game type where if there is nothing to stand on he just falls sorta thing. If you know of a good physics tutorial please tell

  2. #2
    Junior Member
    Join Date
    Oct 2004
    Posts
    2
    there is this it does create a bounce when the MC 'lands' but I'm sure you could change that...

  3. #3
    Senior Member
    Join Date
    Jul 2000
    Location
    Sydney, Australia
    Posts
    486
    change the line velocity *= -0.9 to velocity *= -0.1

    this will create a very small bounce like in mario games

  4. #4
    that does not seem to work out very good, the ball I'm using is suppose to fall off the end of the floor when it moves off of it. It seem to stop in line with the floor even when it is not standing on it.

  5. #5
    Senior Member
    Join Date
    Jul 2000
    Location
    Sydney, Australia
    Posts
    486
    yeah the guy never asked me to include that into the coding

    you can add a line in:

    code:

    onClipEvent(load){
    velocity = 0
    gravity = 2
    friction = 0.01
    }
    onClipEvent(enterFrame){
    velocity += gravity
    velocity -= friction*velocity
    _y += velocity
    if(_y>_root.floor._y && _x<_root.floor._x+_root.floor._width/2 && _x>_root.floor._x-_root.floor._width/2){
    _y = _root.floor._y
    velocity *= -0.1
    }
    }


  6. #6
    Originally posted by a_slosh
    yeah the guy never asked me to include that into the coding

    you can add a line in:

    code:

    onClipEvent(load){
    velocity = 0
    gravity = 2
    friction = 0.01
    }
    onClipEvent(enterFrame){
    velocity += gravity
    velocity -= friction*velocity
    _y += velocity
    if(_y>_root.floor._y && _x<_root.floor._x+_root.floor._width/2 && _x>_root.floor._x-_root.floor._width/2){
    _y = _root.floor._y
    velocity *= -0.1
    }
    }

    THANKYOU!!!!!! it works!!!!

  7. #7
    Senior Member
    Join Date
    Jul 2000
    Location
    Sydney, Australia
    Posts
    486
    np anytime

  8. #8
    x2i GingaNinja's Avatar
    Join Date
    Feb 2004
    Location
    England
    Posts
    217
    Hi im the dude that a_slosh helped to create that garvity with the bounce effect, i realised that the ball did bounce on the same level as the platform and i figured it out myself (thats why i didnt ask for help) i did it with a hitTest. Anyway hope it helped, a_slosh sorted the code out for me which was a big help and i am creating a game because of it.

  9. #9
    Senior Member
    Join Date
    Jul 2000
    Location
    Sydney, Australia
    Posts
    486
    ninja keep us posted with the game, i'd like to see it when it's done

  10. #10
    x2i GingaNinja's Avatar
    Join Date
    Feb 2004
    Location
    England
    Posts
    217
    Its a game called Knuckles Choatix Advance, its basically a flash version of the knuckles chaotix game for the mega drive. Using Sonic Advance style sprites, i havent got the file on me at this point but i shall post a preview as soon as i get it.

    You can jump using the gravity effect you made and you can climb (for some reason he slowly slides back down though nothing too big), there is a boss that you can jump on and bounce off as well.

    There are also a couple of hidden moves as well.

    You shall see when i post it but it will probably be next weekend because i am stopping away at my dads house and it isnt on me. SOZ

    Dan

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