We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Lets just say I have a object, such as a rectangle, and I center it in the screen so (200,200). I want the rectangle to move to (50,50) and I don't want it to jump, I want to see it move to the new coordinates. What is a simple example of how this would work with a rectangle?
Answers
Processing invokes draw() @ about 60 FPS by default. So in order to actually see it moving, you gotta do step by step.
I believe you've already got an answer from your previous thread?
http://forum.processing.org/two/discussion/3315/moving-objects-to-specific-location
There's a simpler 1 below too:
http://forum.processing.org/two/discussion/3319/tween-between-random-positions
A tweaked version:
Okay this seems much clearer. Let me try to understand this logic. So your restart function is sort of similar to a move() function. What is the final float interval? I am confused as the what that does, and the lerp as well... Thank you for your help btw, this is a very clear example, I am just new to animations.
It wasn't be who made that example. So I don't get it 100% either! 3:-O
Nope! It just randomly picks a new destination and draws a colored spot there when interval begins a new cycle!
That expression divides 1 second into FPS units. So interval is the current fractioned value of 1 second.
Hence, it takes about 1 second to reach destination spot, no matter its distance.
It's a little mystery for me as well. Better you read about it for yourself: :(
http://processing.org/reference/lerp_.html