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

2015/8/27

Bouncing Objects Off Other Objects

Camyh15 Camyh15

2015/8/27

#
Hello, how do you make it so that 1 object (the ball in my case), can bounce off another object (the slider)? Do you need to use parameters or just a line of code?
fejfo fejfo

2015/8/27

#
if you use the
move(int )
method to move the ball you can just add a line like this
if(isTouching(Slider.class)) turn(180);
the 180 is for straight bouncing the for bouncing like a mirror it's a little more complex
Camyh15 Camyh15

2015/8/27

#
Thank you sooooooooooooo much!!!!!!!! That's helped a LOT!!!!!!
fejfo fejfo

2015/8/29

#
glad I could help
You need to login to post a reply.