This site requires JavaScript, please enable it in your browser!
Greenfoot back
JERRY**5
JERRY**5 wrote ...

2013/9/17

how to make ball bounce?????

JERRY**5 JERRY**5

2013/9/17

#
can any1 tell me hw to make the ball bounce randomly such that it should appear from the right side of the screen and disappear from left side
Gevater_Tod4711 Gevater_Tod4711

2013/9/17

#
Do you want the ball to bounce off or disappear and appear at the other side of the world? To make the ball bounce you need to know whether your actor is at the end of the world and then just use Greenfoot.getRandomNumber(int) to make the ball bounce randomly. Or have a look at World Wrapping by SPower.
JERRY**5 JERRY**5

2013/9/19

#
the ball should fall from the right side the screen and keep bouncing and should exist from the left side
danpost danpost

2013/9/19

#
The world should add the ball with a random y coordinate and a fixed x coordinate of the right edge of the world. The act method in the class of the ball should make the ball bounce and check for it being at the left edge of the world, at which point it would remove itself from the world.
You need to login to post a reply.