We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi There,
I made a program where you can move a element from right to left with by a lerp function by the left and right cursor. I want to make this code that i can move the element in steps to the right or left. Its now just 1 step.
It is probably very simple to solve this, i can't fix it.
Cheers!
Code:
///
float x = 0; float y = 0;
void setup() { size(500, 400); fill(255, 0, 0); noStroke(); } void draw() { background(255); ellipse(width/2+x, height/2, 20, 20);
if (keyCode == LEFT) { x = lerp(x, -100, 0.1); } if (keyCode == RIGHT) { x = lerp(x, 100, 0.1); } }
//
Answers
Edit post, highlight code, ctrl + o
You don't need lerp() at all!
Thanks for the comment. Exually this option i already used. That works perfectly. I do prefer to use a lerp effect / function to have a transition in the animation from A to B. I was wondering if i could combine the lerp() transition with the option that you gave me.
How bout this?
I wrote it on my phone, so I had to change keyPressed to mousePressed in order to be able to check if it worked.
Thanks!