Avatar billede fredand Forsker
21. april 2004 - 09:59 Der er 3 kommentarer og
1 løsning

Best way for animation?

Hello!

I have a small applet that animate a card that you can flip, front to back, back to front.

But I sometimes experience that the animation skip some frames and makes a small halt before it goes on.

So now I would like to get some comment on my code.

Everything is possible to see at:
http://medlem.spray.se/fredand44/questions/cardflip.html

There you got the applet it self, the code, the UML, and the images. Hopefully so it will be easy for you to make a comment.

BTW please give Svar so I can award you for your participation.

Best regards

Fredrik
Avatar billede _carsten Nybegynder
23. april 2004 - 22:21 #1
I don't know if this will do the trick, but have you ever tried switching these

repaint();
thread.sleep(50);

to

thread.sleep(50);
repaint();

I think you can solve your problem by doing so, because if you created a loop

for(int i = 0; i < 1000; i++){
  repaint();
}

repaint() would of course be called 1000 times, but the AWT paint system will collapse these 1000 calls, to a few calls, maybe just call paint() once.
The paint system will paint when it's in an apropiate state, and it can't get ready that fast.

Well - I'm just gueessing !
Avatar billede fredand Forsker
26. april 2004 - 09:33 #2
Hello Carsten!

Thanks for your reply. I tried to switch the lines but I got it more worse strangely, cause I agree with what you said.

I change all the members to private and that might have sligtly improved it but it is hard to see with your eyes.

Best regards

BTW pleas give Svar so I can award you at the end.

Fredrik
Avatar billede fredand Forsker
13. september 2004 - 19:06 #3
Since you do not give me a answer I take back the points! But thanks for the help!
Avatar billede _carsten Nybegynder
13. september 2004 - 19:45 #4
That's Okay
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester