Hello Guest

Author Topic: Play one animation after another  (Read 3561 times)

tomy45

  • Newbie
  • *
  • Posts: 2
    • View Profile
Play one animation after another
« on: June 09, 2014, 12:03:52 pm »
I will play one clip and then after another tap the second clip. Hope you understand.

Example: First Tap on the Ipad opens a door. The second Tap close it. How can i do this in 2D Toolkit.

Thanks for your help.


Here is the code. It play´s one clip.

using UnityEngine;
using System.Collections;

public class Door : MonoBehaviour {
   
   public tk2dSpriteAnimator DoorClip;
   
   void OnMouseDown() {   
      
      DoorClip.Play();         
   }   
   
}

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Play one animation after another
« Reply #1 on: June 09, 2014, 12:47:20 pm »
You should maintain state yourself.

Code: [Select]
bool doorOpen = false;

OnMouseDown -
if (!doorOpen) {
  DoorAnimator.Play("DoorOpen");
  doorOpen = true;
}
else {
  DoorAnimator.Play("DoorClose");
  doorOpen = false;
}
« Last Edit: June 09, 2014, 12:50:32 pm by unikronsoftware »

tomy45

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Play one animation after another
« Reply #2 on: June 10, 2014, 05:57:55 pm »
Works ! Thanks.
But now I have the problem to reverse the animation clip. How can I do this ?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Play one animation after another
« Reply #3 on: June 10, 2014, 10:33:03 pm »
You cant, not officially anyway. Simply create a reversed version of the clip, Duplicate, then click reverse in the editor.