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 - 4ror

Pages: [1]
1
Support / Re: Swapping sprites in a Hierarchy from another sprite?
« on: October 02, 2012, 07:43:58 pm »
Thanks. When you said array that's what I needed. I created another array of sprites > assigned them in the inspector > in script, pick the element I want to change + elements from another array of sprites and swap on condition... now I've reduced my draw calls a little more.

Thanks again.

2
Support / Re: Swapping sprites in a Hierarchy from another sprite?
« on: October 02, 2012, 05:01:41 pm »
Hi unikron,

thanks for the reply. This is what I've done with individual sprites that share the same script and using an int array to store the ID's of each id in the atlas. But how would a single script know which sprite to swap textures of other sprites? It doesn't work because I think its getting tk2dscript of itself not the other sprites even if I drag the sprites into the var slots arms, mouth in the inspector.

Code: [Select]
var player : tk2dSprite;
var mouth : tk2dSprite;
var arms : tk2dSprite;

player = GetComponent(tk2dSprite);
mouth = GetComponent(tk2dSprite);
arms = GetComponent(tk2dSprite);

// If something happens swap some sprites round
arms.spriteId = spriteIdentity[3];
mouth.spriteId = spriteIdentity[4];

// else swap them back
arms.spriteId = spriteIdentity[1];
mouth.spriteId = spriteIdentity[2];

3
Support / Swapping sprites in a Hierarchy from another sprite?
« on: October 02, 2012, 02:34:57 pm »
Swapping textures on a Character in a hierarchy
I?ve been working on a game and all has been going well. I am new to unity but I have much of it working.  I bought the 2dtk plugin sometime ago but never got round to implementing it. I am now looking at optimising my textures using the texture atlasing feature as this has lowered my draw calls down.

I?ve managed to create an atlas for various level graphics. For example each sprite 3 textures, 2 of them show various levels of visual damage. These spirtes get swap out when a damage is applied. 

My question. I want to use 2dtk for the player textures. It?s slightly more complicated because the player is in a hierarchy. In this hierarchy are eyes, arms, body, and a mouth. They all share the same textures atlas. What I had working originally is when the player falls a distance the character mouth and arms swap textures over to a falling texture, not animated. Also the character eyes blink, hence my reason for separate layered graphics.  I had a javascripted attached to the parent and it would find the gameObject on startup, and swap the textures of the attached using unity?s built in features.  All works great however, I?m not sure how by using one javascript I can swap sprite id?s of another sprite using 2dtk...any tips?

Pages: [1]