2D Toolkit Forum

2D Toolkit => Support => Topic started by: chobi77 on September 08, 2012, 03:45:39 pm

Title: anim.currentClip.name problem.
Post by: chobi77 on September 08, 2012, 03:45:39 pm
Hi all,

I am doing a check to see if an animation is playing so i can get Mario to walk after he lands from a jump and make the jump animation stop.

The problem is that the code  i am using does not work, i have seen examples here and they seem to be working for others so i would like to figure out where i am going wrong.

                       
Code: [Select]
if (velocity.x < 0)
{
velocity *= walkSpeed;
if (anim.isPlaying() && anim.currentClip.name != "MarioSmallWalkLeft")
anim.Play("MarioSmallWalkLeft");
jumpEnable = false;
}

the problem is with the if (anim.isPlaying() && anim.currentClip.name != "MarioSmallWalkLeft") line.

the error i am getting is `tk2dAnimatedSprite.currentClip' is inaccessible due to its protection level.

Can anyone shed any light on why this is happening?

Thanks.
Title: Re: anim.currentClip.name problem.
Post by: unikronsoftware on September 08, 2012, 04:00:52 pm
The one you want is CurrentClip, thats the public property.
Title: Re: anim.currentClip.name problem.
Post by: chobi77 on September 08, 2012, 04:06:38 pm
Thanks for the quick reply.

I changed it to CurrentClip and now i get this error.

Type `tk2dAnimatedSprite' does not contain a definition for `CurrentClip' and no extension method `CurrentClip' of type `tk2dAnimatedSprite' could be found (are you missing a using directive or an assembly reference?)

any ideas?
Title: Re: anim.currentClip.name problem.
Post by: unikronsoftware on September 08, 2012, 04:25:35 pm
Its likely you're using an old version. What version are you on?
Title: Re: anim.currentClip.name problem.
Post by: chobi77 on September 08, 2012, 04:29:56 pm
version 1.51

:)
Title: Re: anim.currentClip.name problem.
Post by: unikronsoftware on September 08, 2012, 04:48:47 pm
Might be a good idea to update, that's an ancient version you've got there...
Title: Re: anim.currentClip.name problem.
Post by: chobi77 on September 08, 2012, 05:14:01 pm
Oh wow yes, that never occurred to me...

Seems i also have to upgrade Unity to 3.5.5 as well.

Thanks for that, i hope all this works when i finish upgrading.  :)