home *** CD-ROM | disk | FTP | other *** search
/ ring.yamanashi.ac.jp/pub/pc/freem/action/ / action.zip / baku100.zip / baku100 / Kernel / Util / AnimationAdaptor.tonyu < prev    next >
Text File  |  2002-12-23  |  2KB  |  83 lines

  1. extends PlainChar;
  2.  
  3. /*resvFé¬éóéΘù¥ùR:
  4. an.loop(10,11,2);
  5. an.loop(12,13,2);
  6. an.loop(10,11,2);
  7.  
  8. é▒éΩé≡ô»é╢âtâîü[âÇé┼Ä└ìsé╡é╜é╞é½üA10-11é╠âAâjâüü[âVâçâôé╠âèâZâbâgé≡ûhé«
  9. */
  10. constructor AnimationAdaptor(t) {
  11.   target=t;
  12.   mode=3;
  13.   spd=3;
  14. }
  15.  
  16. function play(ff,tt,s) {
  17.   resvF=ff;resvT=tt;resvM=0;
  18.   paused=0;
  19.   if (s) spd=s;
  20. }
  21. function loop(ff,tt,s) {
  22.   resvF=ff;resvT=tt;resvM=1;
  23.   paused=0;
  24.   if (s) spd=s;
  25. }
  26. function swing(ff,tt,s) {
  27.   resvF=ff;resvT=tt;resvM=2;
  28.   paused=0;
  29.   if (s) spd=s;
  30. }
  31.  
  32. function update3() {
  33.   if (target.isDead()) die();
  34.   update();
  35.   if (f==resvF) return 0;
  36.   f=resvF;t=resvT;mode=resvM;
  37.   if (mode!=3 && resvF>=0) target.p=f; 
  38.   return 1;
  39. }
  40.  
  41. function stop() {
  42.   f=-1;resvF=-2;
  43.   resvM=3;
  44. }
  45.  
  46. function update2(wt) {
  47.   while (wt>0) {
  48.     if (update3()) return 1;
  49.     if (!paused) wt--;
  50.   }
  51.   return 0;
  52. }
  53.  
  54. function pause() {
  55.   paused=1;
  56. }
  57. function resume() {
  58.   paused=0;
  59. }
  60.  
  61. while (mode>=0) {
  62.   while (mode==0) { // play
  63.     if (update2(spd)) break;
  64.     target.p++;
  65.     if (target.p>=t) stop();
  66.   }
  67.   while (mode==1) { // loop
  68.     if (update2(spd)) break;
  69.     target.p++;
  70.     //print(target.p+"//"+target+"//"+f+"-"+t);
  71.     if (target.p>t) target.p=f;
  72.   }
  73.   while (mode==2) { // swing
  74.     if (update2(spd)) break;
  75.     if (target.p>=t) swv=-1;
  76.     if (target.p<=f) swv=1;
  77.     target.p+=swv;
  78.   }
  79.   while (mode==3) {
  80.     if (update3()) break;
  81.   }
  82. //  print(mode+"<>"+target.p+"/-/"+target+"//"+f+"-"+t);
  83. }