2017년 4월 20일 목요일

Flung ball leaving trail


I am creating a basic app with a ball that is flung around the screen. Is there any way to make the ball leave a trail of color behind? Like the ball draws a line while it moves randomly around the screen.

--
Yes, see the attachment. 
-- 
It didnt work

-- 
I tried that. Here's a screenshot.
What it did was leave one big box of paint behind. It did not leave a continuous trail.
I tried it as a procedure, too, and that didn't work either. 
Any ideas?
-- 
You need to save the current x and y in variables called Prev_x and Prev_y.
Then everytime the ball is moved, draw a line from Prev_x, Prev_y to the current x and y of the ball. After the line is drawn, repeat (save x and y, etc.)


--
Thanks for the suggestion! I tried that and made it with a procedure - see my screenshot.
The problem is, it still only draws little lines every time I fling the ball.
How do I save in order to repeat as you suggested?
-- 
The x,y saving and the drawing needs to be done inside a Clock.Timer event, set that timer to enabled when the ball is flung. Set the clock to 100 ms or anything that works for you.

--

댓글 없음:

댓글 쓰기