A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: bouncing

  1. #1
    Junior Member
    Join Date
    Oct 2004
    Posts
    2

    bouncing

    hello
    trying to make like these old black and white padle games, i wrote this script :

    { ball = element.("ball");
    rpadle = element.("right padle");

    ball.velocity.x=128;

    if (ball.collideRect (rpadle){
    ball.velocity.x *= -1;
    }
    }

    (i m writing it here by memory, the real syntax is ok, that s not the pbme)

    I play this once per frame but problem is that when the ball comes to the pabble it goes the other way (just fine!) but just after this, the same collision is detected one more time and ball switches velocity and move back to paddle and so on, the ball keeps on going back and forth fast in front of the paddle.

    Ball and paddle both are rectangular Paints.

    any ideas ???
    he who wakes up late sleeps longer...
    .. but misses the early cartoons

  2. #2
    Ride 'em FISHY! neederofhelp's Avatar
    Join Date
    Oct 2003
    Location
    I Forgot!
    Posts
    217
    Post it. That way we can see it first hand and tell you what the problem is.
    Dan

    Oops. I broke it.... again.

  3. #3
    Junior Member
    Join Date
    Oct 2004
    Posts
    2

    it works !! :)

    i don t have the movie with me to post it but i managed to make it work :
    for those interested, pbm was that the speed variable values were given in the same script so it kept on doing :
    speed_x = 128, detect colision -> speed_x *= -1; then the loop went on :
    speed_x = 128, colision -> speed_x *= -1, etc. and the ball kept on shaking in front of the paddle.

    so i gave initial values in a script that is ran once located in the'Event zone', and the colision script works each frame from the 'elements' zone with its own speed variables. (I don't know if this can be understood the way I explained this )

    Next thing will be to set a fine vertical 'effect' from the paddle.

    i ll post the movie later.
    he who wakes up late sleeps longer...
    .. but misses the early cartoons

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