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 - sneenlantern

Pages: [1]
1
thanks, Unikron, that was it.  I really appreciate your help.  I'll be back for the next problem later.   ;)

2
Support / Scripting Animation according to documentation problems
« on: April 16, 2012, 12:19:47 pm »
Hi, forgive me if this is stupid, I'm new to both 2d Toolkit and Unity.  But I followed the documentation exactly until it came to scripting the animation and I made some changes and I'm not sure if I made them correctly or if I made enough.  This is what the result looks like:



As you can see on the left there's no sprite, and when you run the game it's just a gray square.  This is my code I'm running:

using System.Collections;

public class TutorialAnimController : MonoBehaviour
{
   tk2dAnimatedSprite anim;

   // Use this for initialization
   void Start () {
      anim = GetComponent<tk2dAnimatedSprite>();
   }

   bool walking = false;

   void HitCompleteDelegate(tk2dAnimatedSprite sprite, int clipId)
   {
      if (walking)
      {
         anim.Play("walk");
      }
      else
      {
         anim.Play("idle");
      }
   }

   // Update is called once per frame
   void Update ()
   {
      if (Input.GetKeyDown(KeyCode.F))
      {
         anim.Play("hit");
         anim.animationCompleteDelegate = HitCompleteDelegate;
      }
         if (Input.GetKeyDown(KeyCode.Space))
      {
         anim.Play("jump");
         anim.animationCompleteDelegate = null;
         walking = false;
      }
      if (Input.GetKeyDown(KeyCode.RightArrow))
      {
         anim.Play("walk");
         anim.animationCompleteDelegate = null;
         walking = true;
      }
      
      if (Input.GetKeyDown(KeyCode.LeftArrow))
      {
         anim.Play("walkleft");
         anim.animationCompleteDelegate = null;
         walking = true;
      }
   }
}


Has anyone got the time to take a look at this and tell me what I'm doing wrong?  Should I be naming the animation somewhere in the script?  I'm not now.  Should I even be doing this in scripting?  Should I be doing this in Playmaker or something?  I just tried to follow the documentation. 

Please help.  Thanks for reading. 

Pages: [1]