Pausing and continuing an animation in App Designer
1 次查看(过去 30 天)
显示 更早的评论
Hey everyone I'm trying to pause an animation I made.
Following is the loop that generates the animation.
Before, the position over time of the falling objects are calculated and saved as a vector.
Objects are generated by the patch command.
With every iteration of the loop the new position is shown in a figure.
tu is the time the objects fall until they hit the ground.
tf is a vector with the time intervals between 0 and tu.
tf consists of as many columns as needed to guarantee 25 frames per seconds.
So far everything works as planed.
%Schleife zur Animation
q = 1;
time = 0;
tic;
while time < tu
time = toc;
%Anzeigewerte
app.GeschwindigkeitEditField.Value = vt(q);
app.aktuelleZeitEditField.Value = tf(q);
app.StreckeEditField.Value = st(q);
app.kinetischeEnergieEditField.Value = Ekin(q);
app.potentielleEnergieEditField.Value = Epot(q);
app.GesamtenergieEditField.Value = Eges(q);
app.rotatorischeEnergieEditField.Value = 0; % visualisation of Information about velocity, energy, time etc.
%Position der Scheibe
Kreis.XData = xAkreis + R;
Kreis.YData = yAkreis + y(q); % positon of first falling object
InnenKreis.XData = xIkreis + R;
InnenKreis.YData = yIkreis + y(q); % positon of second falling object
%Grenzen des Diagramms
xlim([-R 20+R]);
ylim([-H-Boden*3/2 R+2]);
pau = tf(q) - toc;
pause(pau); % forcing matlab to wait until predefined time (tf)
q = q + 1;
if q > length(tf)
q = length(tf);
end
end
I now want to pause my animation at any point and continue it at the same point.
I tried a second infinite while loop inside the first one that is started by using a switch in app designer but if it started it started with different delays and didn't continue after I used the switch again.
Thanks for any help!
4 个评论
MSolano
2021-7-7
I'm having a very similar issue, but I just can't find the answer, how were you able to solve this?? Just with the if and while loops inside your animation loop?
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!