A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: collision detection

  1. #1
    Senior Member
    Join Date
    Jul 2000
    Posts
    198

    Post

    I need help with some collision detection. I need to know how to move guy on a platform, and he won't fall down. Like in mario bros

  2. #2
    Junior Member
    Join Date
    Jul 2000
    Posts
    4
    well find out the location of the platform and the player(/mcname:_x /mcname:_y) - half the width and half the width to find out the x1, x2, y1, y2 and see if the player is within the bounderies. look at basic collision detection to make it easier to understand.

    let me know if this helps out

    Balishake

  3. #3
    Senior Member
    Join Date
    Jul 2000
    Posts
    198
    I know how to do that. But i don't know how to make it so he wont fall off platform, here's a diagram:

    0
    /||\
    _____/\____
    |
    |
    _____________________

    I want him so he stays on a platform like shown, then he could fall off and land on the lower platform. Understand?

  4. #4
    Senior Member
    Join Date
    Jul 2000
    Posts
    198
    that diagram didn't turn out how i wanted it to...
    Hope you get the idea

  5. #5
    find out how large (in pixels) your top platform is.
    say it's 100 x 10 pixels, and your dude graphic is 20x20 pixels...

    given your dude starts atop the first platform:

    if (/player_x + 10 < /top_platform_x + 50 and /player_x - 10 > /top_platform_x - 50)
    //then keep character at same y value.
    else
    //set property ("player",_y) = getproperty("player",_y) - 5
    //and repeat until /player_y is the value of the lower_platform_y

    that's how i'd do it.

    -pork

  6. #6
    Senior Member
    Join Date
    Jul 2000
    Posts
    198
    ok i c. thnx.

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