Why this code doesn't work properly? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why this code doesn't work properly?

This is an UI that makes a ball go down in a diagonal way, but the ball stays static; it seems something is not working adecuatedly with the threads. Could you please, tell me how to make the ball move? https://code.sololearn.com/cEd16IG11o9J/#java

20th Sep 2019, 2:34 AM
Steve
Steve - avatar
1 Answer
0
OK, I had already solved it. It wasn't moving because I hadn't created an instance of the Layout that I was working on, so the thread didn't have connection with the ball and the coordinates; but, I managed to solve it. Updated code: https://code.sololearn.com/cEd16IG11o9J/#java Unfortunately, I have now another problem and it is that every time I hit the button "¡Animate it!" it doesn´t create a new ball. Also, when I hit it twice the ball speeds up; As if the coordinates get accumulated in some way. Could you explain me please, why it's not creating a new one; why the ball's speed is incrementing and how to make it bounce within the limits of the frame?
24th Sep 2019, 2:33 AM
Steve
Steve - avatar