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

Pages: [1]
1
Support / Re: Switching the Anim Lib in tk2dAnimatedSprite objects
« on: June 13, 2014, 07:00:25 pm »
Exciting news! Scratch my last couple of posts.

I can get the sprite animations to change to the female sprite, by using var sprite : tk2dAnimatedSprite, and changing sprite.anim to my loaded prefab.

However, there is still a slight problem: when one jumps into the game, they appear as a male at first and the sprite only changes once you start moving. This happens at the start of every level. Could this have to do with the fact that we are controlling this variable using our playerMovement script? Obviously, it is unacceptable to start as the male and then magically transform into the female, so I would like to clear this problem up. Thanks so much for your help so far, couldn't have done it without these forums (at least, it would have taken far too long  ;D ).

2
Support / Re: Switching the Anim Lib in tk2dAnimatedSprite objects
« on: June 13, 2014, 05:58:29 pm »
And by the way, Resources.Load is returning the correct object, femaleSpriteAnimation or maleSpriteAnimation, so we're on the right track there.

3
Support / Re: Switching the Anim Lib in tk2dAnimatedSprite objects
« on: June 13, 2014, 05:56:45 pm »
Alright, so if I define var sprite : tk2dSpriteAnimator; , I get an error saying that tk2dSpriteAnimator is an unrecognized type, and Unity tells me to switch to tk2dSprite. What's going on there? If Sprite is the tk2dAnimatedSprite object attached to the player, why am I trying to define it as a tk2dSpriteAnimator?

If I change it to tk2dSprite, I still get the MissingFieldException: tk2dAnimatedSprite.Library because I am still using the tk2dAnimatedSprite object attached to player as my sprite object in the Unity editor. These errors seem odd to me, I can't really pin down where they're coming from. The messages seem to be all over the place.

4
Support / Re: Switching the Anim Lib in tk2dAnimatedSprite objects
« on: June 12, 2014, 04:57:10 pm »
Okay, having followed instructions to the best of my ability, I am still getting errors.

I ran Setup for Javascript a couple of times, just to be sure it worked.

I'm using Resources.Load("maleSpriteAnimation",tk2dSpriteAnimation) to load the prefab sprite animations to a tk2dSpriteAnimation object called newLib. The prefabs I will be using have been placed in a Resources folder within the Assets directory. Am I doing this step correctly?

As far as the third step goes, the way I'm currently executing is causing an error. I tried to make a field called sprite with the following: private var sprite : tk2dAnimatedSprite; . I drag and drop the tk2dAnimatedSprite component from the player object into this field in the editor. I then use the following code to assign the library: sprite.Library = newLib; , where newLib is (supposedly) the maleSpriteAnimation or femaleSpriteAnimation.

Where am I going wrong? Thanks again for helping, this problem has been a constant annoyance for some time.

5
Support / Switching the Anim Lib in tk2dAnimatedSprite objects
« on: June 12, 2014, 02:33:24 am »
Hello all. I'd like to preface this by saying that I know many similar questions have been asked about what I'm about to jump in to, but I can't find any answers to my particular problem.

While developing a Unity game using the 2D Toolkit, my team and I have run into a problem. At the start of the game, one may choose to be a male or female character. The default sprite library currently under use is the one for the male character, but we'd like to enable our female sprite animations.

We are writing a playerMovement script (all of our scripting is done in javascript) which is attached to the player object, and the playerMovement script will be doing the actual switching between male and female sprite collections. A script attached to the character selection scene changes a variable in the GLOBAL script in order to keep track of player gender for playerMovement. Currently, our implementation can succesfully change the GLOBAL variable to correspond to the male or female selections, and the character select scene works fine. The problem lies in the actual switching of sprite collections.

Once we have collected the GLOBAL variable, we need to change the Anim Lib of the tk2dAnimatedSprite component which is attached to the player gameobject. If I manually change the Anim Lib field in the tk2dAnimatedSprite from maleSpriteAnimations.prefab to femaleSpriteAnimations.prefab in the editor, the game runs with the female character just fine. However, we can simply not figure how to access the C Sharp fields and code that the 2D Toolkit uses from our javascript to make this run correctly. Moreover, we don't know exactly how to specify that it's a prefab that we're using from within code and to make sure the right file is being referenced.

Any help on this is greatly appreciated, I hope I've given enough detail. Thanks everyone.

Pages: [1]