Hello Guest

Author Topic: Reference problems  (Read 5417 times)

cypher123

  • Newbie
  • *
  • Posts: 8
    • View Profile
Reference problems
« on: July 17, 2013, 04:57:20 pm »
My main question is how do I reference the tk2d scripts without causing massive problems.
My problems are I am following the sample animator script and I want to reference that script but It says tk2dSpriteAnimator and tk2dSpriteAnimationClip are missing using directives, so I added tk2dSpriteAnimator  and tk2dSpriteAnimation to my solution that seems to solve the reference problem but then I get instant errors in unity about those two scripts namespace already being in global::.
Any suggestions?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Reference problems
« Reply #1 on: July 17, 2013, 06:48:42 pm »
Can you post a step by step of what you're trying to do here? Are you trying to reference from JS? Have you run Setup for JS? I don't have enough info to be able to suggest anything here.

cypher123

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Reference problems
« Reply #2 on: July 17, 2013, 08:45:46 pm »
I'm using C# and I have created the tutorialanimcontroller.cs you have on your site and it is giving me using errors for tk2dSpriteAnimator and tk2dSpriteAnimationClip, So I add the tk2dSpriteAnimation.cs and tk2dSpriteAnimator.cs to my solution and it seems to resolve the reference errors but in unity I get Assets/TK2DROOT/tk2d/Code/Sprites/tk2dSpriteAnimator.cs(9,14) error : the namespace 'global::'  already contains a definition for tk2dSpriteAnimation and the same for spriteanimation. I run the integrity checker before I add them to my solution and it says it is fine but after it says the same errors. Overall I have a sprite with an animation and also the tutorialanimcontroller.cs is attached and I'm trying to have it so I can access that tutorialanimcontroller.cs in another script called battle.cs and to change it when certain animations should play based on what happens in the battle.cs.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Reference problems
« Reply #3 on: July 17, 2013, 09:22:08 pm »
Can you paste the exact error here?

How did you add tk2dSpriteAnimation / SpriteAnimator to the solution? They should already be in your Unity project and thats all that matters. What solution are you referring to here? Where did you find these files?

Where did you put the tutorialanimcontroller.cs file?

cypher123

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Reference problems
« Reply #4 on: July 18, 2013, 02:43:42 pm »
Assets/TK2DROOT/tk2d/Code/Sprites/tk2dSpriteAnimator.cs(9,14): error CS0101: The namespace `global::' already contains a definition for `tk2dSpriteAnimator'

is the error, I get the same error just for different .cs files.

So This is how I created the animations, I made a tk2dcollection and a tk2danimation. I created a empty gameobject and added tk2dSprite and tk2dspriteanimator and added the tutorialanimcontroller.cs to the gameobject as well. I'm refering to a solution in my visual studios that contains my scripts for my unity project, but doesn't contain the tk2d scripts.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Reference problems
« Reply #5 on: July 18, 2013, 02:53:20 pm »
That error message implies you have 2 copies of the same script in your project. This shouldn't have happened. Check your Unity project to see why there are 2 copies of the same script.

cypher123

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Reference problems
« Reply #6 on: July 18, 2013, 07:48:25 pm »
thanks that worked, do you mind if i ask another question here? about AnimationCompleted how does it work exactly because I have it like so.

void PlayIdle(tk2dSpriteAnimator sprite, tk2dSpriteAnimationClip clip) {
      anim.Play("idle");
      attack = false;
   }
   

   void Update() {
      Debug.Log("attack: " + attack);
      if (attack == true) {
         if (!anim.IsPlaying("attack")) {
            anim.Play("attack");
            anim.AnimationCompleted = PlayIdle;
            
            
         }


thats just a small bit, but it doesn't seem to stop the attack animation at all when I set it to true from another script.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Reference problems
« Reply #7 on: July 18, 2013, 08:23:48 pm »
The order things happen in Unity is more or less undefined (unless you want to do a LOT of work to ensure order). Your script is doing things in Update checking some state, which is turned off elsewhere. Update might be called before the delegate is called, and will restart playback.