Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Lami

Pages: [1]
1
Support / AnimationCompleteDelegate Problem
« on: February 21, 2013, 02:49:21 pm »
Hello!

I'm trying to sequence some animations but it doesn't work as I expect it.
The Problem is that animation 2 immediatly starts even if animation 1 has not finished.
Maybe I'm missing something, so here's the code:

function raise () {
   var thomb: tk2dAnimatedSprite = null;
   for (thomb in thombScatterIcons) {
      thomb.SetFrame(1);
      var anim:tk2dAnimatedSprite;
      anim = Instantiate(prefab_anim,Vector3(thomb.transform.position.x, thomb.transform.position.y, thomb.transform.position.z-0.1),Quaternion.identity);
      switch (Random.Range(1, 6)) {
         case 1:
                  anim.Play("plain_rise");
                  anim.animationCompleteDelegate = switchAnimToIdleMode(anim,1);
                  break;
            case 2:
                  anim.Play("pylon_rise");
                  anim.animationCompleteDelegate = switchAnimToIdleMode(anim,2);
                  break;
            case 3:
                  anim.Play("bucket_rise");
                  anim.animationCompleteDelegate = switchAnimToIdleMode(anim,3);
                  break;
            case 4:
                  anim.Play("football_rise");
                  anim.animationCompleteDelegate = switchAnimToIdleMode(anim,4);
                  break;
            case 5:
                  anim.Play("yeti_rise");
                  anim.animationCompleteDelegate = switchAnimToIdleMode(anim,5);
                  break;
       }
   }
}
function switchAnimToIdleMode(anim:tk2dAnimatedSprite,Id:int)
{
   switch (Id) {
         case 1:
                  anim.Play("plain_idle");
                  break;
            case 2:
                  anim.Play("pylon_idle");
                  break;
            case 3:
                  anim.Play("bucket_idle");
                  break;
            case 4:
                  anim.Play("football_idle");
                  break;
            case 5:
                  anim.Play("yeti_idle");
                  break;
    }
    return null;
}

Pages: [1]