Hello.
Imagine i want to slide a panel down to the y=200 on the screen. from y=0;
i do it: while(panel.pos_y<200){
panel.pos_y+=1*time_step;
wait(1);
}
But sometimes, i check that the final y its not 200, but 199 or something depending on the lag..
How can i avoid that? without the time_step it gets shaky or slides very quickly.
It is very unlikely that panel.pos_y is precisely 200 after the loop. Example:
- panel.pos_y is 199.873
- assume that time_step was 0.527 in the last frame
- next iteration:
while(panel.pos_y<200){
panel.pos_y+=1*time_step;
wait(1);
}
- panel.pos_y is now 200.4 -> end of loop
I hope you know what time_step does/ is/ how it is calculated. Otherwise have a look at the manual.
Solution:
while(panel.pos_y<200){
panel.pos_y+=1*time_step;
wait(1);
}
panel.pos_y = 200;