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

Pages: [1]
1
Support / Re: Showing part of a sprite
« on: September 29, 2013, 10:51:33 am »
Ok, tnx!

Just wanted to say I love your product and support. Keep it up... :)

2
Support / Re: Showing part of a sprite
« on: September 28, 2013, 03:24:20 pm »
Ok, discard all of my questions I got it working...

I made a prefab from tk2dclippedsprite and I'm instantiating as much as want.
I just hope they are not copying the texture each time...

Anyway, tnx :)

3
Support / Re: Showing part of a sprite
« on: September 28, 2013, 01:20:29 pm »
Or better yet can I use clipped sprite to make a new sprite from that clipped area?

That is actually what I need...

4
Support / Re: Showing part of a sprite
« on: September 28, 2013, 12:42:39 pm »
Tnx, should of figure out that by myself..

I got it working but need another feature. Is there a way to give clipped sprite a list of rects to be shown?
Because I want to have fractions of texture to be visible which are not connected to each other

5
Support / Showing part of a sprite
« on: September 25, 2013, 10:06:23 pm »
Is there any way that I can show a fraction of a texture like for example a health bar that's on 45%...

I'm not implementing a health bar but it's the simplest way to explain my problem :)

So basically,  is there a way to show only a part of texture defined with a Rect or something like that?

Tnx

6
Support / Re: Problem with changing a sprite at runtime
« on: August 13, 2013, 04:10:41 pm »
I found what was the problem. I probably didn't understood you right. When you said "Try this background_sprite.SetSprite( newCollection, sprite_name );", did you mean try only with this or after these two lines?

background_sprite.Collection   = Resources.Load(collection_name, typeof(tk2dSpriteCollectionData)) as tk2dSpriteCollectionData;
background_sprite.spriteId = background_sprite.Collection.GetSpriteIdByName(sprite_name);


Anyway, I used my old code and then wrote your line and this is wrong because of this part of code:

public void SetSprite(tk2dSpriteCollectionData newCollection, int newSpriteId) {
   bool switchedCollection = false;
   if (Collection != newCollection) {
      collection = newCollection;
      collectionInst = collection.inst;
      _spriteId = -1; // force an update, but only when the collection has changed
      switchedCollection = true;
   }
   
   spriteId = newSpriteId;
   
   if (switchedCollection) {
      UpdateMaterial();
   }
}

In my case UpdateMaterial() would never be called. Now I'm loading a sprite collection from resource and only calling SetSprite function without explicitly assigning new collection and spriteId. I don't know if this is wanted behavior, maybe a Collection set function should call UpdateMaterial...

Tnx for your help and speed... :)

7
Support / Re: Problem with changing a sprite at runtime
« on: August 13, 2013, 03:44:05 pm »
Yes, after it's loaded, the correct collection and sprite are in the inspector. That's why it's so confusing to me...

8
Support / Re: Problem with changing a sprite at runtime
« on: August 13, 2013, 03:34:59 pm »
Tnx for the help, but it's still the same...

9
Support / Re: Problem with changing a sprite at runtime
« on: August 13, 2013, 03:23:05 pm »
Yes it is.
When I run the game and select background from hierarchy window, inspector shows correct collection and sprite but the game has the old background...

10
Support / Problem with changing a sprite at runtime
« on: August 13, 2013, 02:02:05 pm »
I have a problem with displaying a loaded sprite at runtime. This is my code:

tk2dSprite background_sprite = background.GetComponent<tk2dSprite>();
      
string collection_name;
string sprite_name;

if (Level == 1)
{
   collection_name = "SpaceBackground_02";
   sprite_name    = "space_02";
}
else
{
   collection_name = "SpaceBackground_01";
   sprite_name    = "space_01";
}

background_sprite.Collection   = Resources.Load(collection_name, typeof(tk2dSpriteCollectionData)) as tk2dSpriteCollectionData;
background_sprite.spriteId = background_sprite.Collection.GetSpriteIdByName(sprite_name);

Anyway, I start with level 1 and this is a test code to see if dynamic loading will work. I've set up space_01 background in unity editor, but on level start I have this code above executing and it should change the background to space_02 but that doesn't happen. The funny thing is that I see my change in the inspector, but the background stays the same in the game...

I'm obviously missing something here, please help :)

Pages: [1]